fix: 修复部署到华为cdn,子账号ak查询不到域名的bug

pull/409/head
xiaojunnuo 2025-05-27 12:02:54 +08:00
parent 818998259d
commit ebb292a2f7
1 changed files with 17 additions and 0 deletions

View File

@ -31,6 +31,14 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
@TaskInput(createCertDomainGetterInputDefine({ props: { required: false } }))
certDomains!: string[];
@TaskInput({
title: '企业项目ID',
helper: '华为云子账号必填,"all"表示查询所有项目',
required: false,
value:"all"
})
enterpriseProjectId!: string;
@TaskInput({
title: 'Access授权',
helper: '华为云授权AccessKeyId、AccessKeySecret',
@ -52,6 +60,8 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
)
domains!: string[];
async execute(): Promise<void> {
if (!this.cert) {
throw new Error('域名证书不能为空');
@ -84,6 +94,9 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
this.logger.info('部署到域名:', domain);
const queryReq = new cdn.ShowDomainDetailByNameRequest(domain);
if(this.enterpriseProjectId){
queryReq.withEnterpriseProjectId(this.enterpriseProjectId)
}
const domainDetail = await client.showDomainDetailByName(queryReq);
//@ts-ignore
const status = domainDetail.domain.domainStatus || domainDetail.domain.domain_status
@ -94,6 +107,9 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
}
try{
const req = new cdn.UpdateDomainFullConfigRequest().withDomainName(domain).withBody(body);
if(this.enterpriseProjectId){
req.withEnterpriseProjectId(this.enterpriseProjectId)
}
await client.updateDomainFullConfig(req);
this.logger.info(`部署到域名${domain}完成:`);
}catch (e) {
@ -129,6 +145,7 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
const request = new cdn.ListDomainsRequest();
request.pageNumber = 1;
request.pageSize = 1000;
request.enterpriseProjectId = this.enterpriseProjectId || undefined;
const result: any = await client.listDomains(request);
if (!result || !result.domains || result.domains.length === 0) {
throw new Error('未找到CDN域名您可以手动输入');