mirror of
https://github.com/certd/certd.git
synced 2026-05-19 07:37:36 +08:00
fix: 修复京东云报错不准确的bug
This commit is contained in:
@@ -174,7 +174,7 @@ export default async (client, userOpts) => {
|
||||
|
||||
|
||||
} catch (e) {
|
||||
log(`[auto] [${d}] challengeCreateFn threw error: ${e.message}`);
|
||||
log(`[auto] [${d}] challengeCreateFn threw error: ${e.message || e}`);
|
||||
await deactivateAuth(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -244,10 +244,11 @@ export class AccessService extends BaseService<AccessEntity> {
|
||||
}
|
||||
const newAccess = {
|
||||
...access,
|
||||
userId:-1,
|
||||
id: undefined,
|
||||
projectId,
|
||||
}
|
||||
await this.add(newAccess);
|
||||
await this.repository.save(newAccess);
|
||||
return newAccess.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ export class JDCloudAccess extends BaseAccess {
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const service = await this.getJDDomainService();
|
||||
const domainRes = await service.describeDomains({
|
||||
const domainRes = await this.catchCall(() => service.describeDomains({
|
||||
domainName: req.searchKey,
|
||||
pageNumber: pager.pageNo,
|
||||
pageSize: pager.pageSize,
|
||||
})
|
||||
}))
|
||||
let list = domainRes.result?.dataList || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.domainId,
|
||||
@@ -85,7 +85,17 @@ export class JDCloudAccess extends BaseAccess {
|
||||
list,
|
||||
};
|
||||
}
|
||||
|
||||
async catchCall<T=any>(fn: () => Promise<T>): Promise<T> {
|
||||
try {
|
||||
return await fn();
|
||||
} catch (e) {
|
||||
if (e.error) {
|
||||
this.ctx.logger.error(JSON.stringify(e.error))
|
||||
throw new Error(JSON.stringify(e.error))
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new JDCloudAccess();
|
||||
|
||||
@@ -54,8 +54,7 @@ export class JDCloudDnsProvider extends AbstractDnsProvider {
|
||||
* weight Integer False 解析记录的权重,目前支持权重的有:A/AAAA/CNAME/JNAME,A/AAAA权重范围:0-100、CNAME/JNAME权重范围:1-100。
|
||||
* viewValue Integer True 解析线路的ID,请调用describeViewTree接口获取基础解
|
||||
*/
|
||||
try{
|
||||
const res = await service.createResourceRecord({
|
||||
const res = await this.access.catchCall(() => service.createResourceRecord({
|
||||
domainId: domainId,
|
||||
req: {
|
||||
hostRecord: hostRecord,
|
||||
@@ -64,31 +63,21 @@ export class JDCloudDnsProvider extends AbstractDnsProvider {
|
||||
ttl: 200,
|
||||
viewValue: -1,
|
||||
}
|
||||
})
|
||||
}))
|
||||
return {
|
||||
recordId: res.result.dataList.id,
|
||||
domainId: domainId
|
||||
};
|
||||
}catch (e) {
|
||||
if (e.error){
|
||||
this.logger.error(JSON.stringify(e.error))
|
||||
throw new Error(JSON.stringify(e.error))
|
||||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
async removeRecord(options: RemoveRecordOptions<any>): Promise<any> {
|
||||
const record = options.recordRes;
|
||||
|
||||
const service = await this.getJDDomainService();
|
||||
await service.deleteResourceRecord({
|
||||
await this.access.catchCall(() => service.deleteResourceRecord({
|
||||
domainId: record.domainId,
|
||||
resourceRecordId: record.recordId
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
private async getJDDomainService() {
|
||||
|
||||
@@ -71,7 +71,7 @@ export class JDCloudDeployToCDN extends AbstractTaskPlugin {
|
||||
this.logger.info(`开始上传证书`);
|
||||
|
||||
const sslService = await this.getSslClient(access);
|
||||
const res = await sslService.uploadCert({
|
||||
const res = await access.catchCall(() => sslService.uploadCert({
|
||||
// certName String True 证书名称
|
||||
// keyFile String True 私钥
|
||||
// certFile String True 证书
|
||||
@@ -80,7 +80,7 @@ export class JDCloudDeployToCDN extends AbstractTaskPlugin {
|
||||
keyFile: certInfo.key,
|
||||
certFile: certInfo.crt,
|
||||
aliasName: certName
|
||||
});
|
||||
}));
|
||||
certId = res.result.certId;
|
||||
}
|
||||
|
||||
@@ -152,10 +152,10 @@ export class JDCloudDeployToCDN extends AbstractTaskPlugin {
|
||||
* pageNumber Integer False 1 pageNumber,默认值1
|
||||
* pageSize
|
||||
*/
|
||||
const res = await service.getDomainList({
|
||||
const res = await access.catchCall(() => service.getDomainList({
|
||||
pageNumber: 1,
|
||||
pageSize: 50
|
||||
});
|
||||
}));
|
||||
// @ts-ignore
|
||||
const list = res?.result?.domains;
|
||||
if (!list || list.length === 0) {
|
||||
|
||||
@@ -85,7 +85,7 @@ export class JDCloudUpdateCert extends AbstractTaskPlugin {
|
||||
const certInfo = this.cert as CertInfo
|
||||
for (const certId of this.certIds) {
|
||||
this.logger.info(`开始更新证书:${certId}`)
|
||||
const res = await service.updateCert({
|
||||
const res = await access.catchCall(() => service.updateCert({
|
||||
/*
|
||||
@param {string} opts.certId - 证书Id
|
||||
@param {string} opts.certId - 证书ID
|
||||
@@ -96,7 +96,7 @@ export class JDCloudUpdateCert extends AbstractTaskPlugin {
|
||||
certId,
|
||||
certFile: certInfo.crt,
|
||||
keyFile:certInfo.key,
|
||||
})
|
||||
}))
|
||||
this.logger.info(`更新证书${certId}成功:${JSON.stringify(res)}`);
|
||||
await this.ctx.utils.sleep(2000)
|
||||
}
|
||||
@@ -126,10 +126,10 @@ export class JDCloudUpdateCert extends AbstractTaskPlugin {
|
||||
* pageNumber Integer False 1 pageNumber,默认值1
|
||||
* pageSize
|
||||
*/
|
||||
const res = await service.describeCerts({
|
||||
const res = await access.catchCall(() => service.describeCerts({
|
||||
pageNumber: 1,
|
||||
pageSize: 100,
|
||||
})
|
||||
}))
|
||||
// @ts-ignore
|
||||
const list = res?.result?.certListDetails
|
||||
if (!list || list.length === 0) {
|
||||
|
||||
@@ -61,7 +61,7 @@ export class JDCloudUploadCert extends AbstractTaskPlugin {
|
||||
const service = await this.getClient(access);
|
||||
|
||||
const certInfo = this.cert as CertInfo;
|
||||
const res = await service.uploadCert({
|
||||
const res = await access.catchCall(() => service.uploadCert({
|
||||
/*
|
||||
@param {string} opts.certName - 证书名称
|
||||
@param {string} opts.keyFile - 私钥
|
||||
@@ -71,7 +71,7 @@ export class JDCloudUploadCert extends AbstractTaskPlugin {
|
||||
certName: this.appendTimeSuffix(this.certName || "certd"),
|
||||
certFile: certInfo.crt,
|
||||
keyFile: certInfo.key
|
||||
});
|
||||
}));
|
||||
this.jdcloudCertId = res.result.certId;
|
||||
this.logger.info(`上传证书成功:${JSON.stringify(res)}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user