diff --git a/pkg/core/deployer/providers/aliyun-clb/aliyun_clb.go b/pkg/core/deployer/providers/aliyun-clb/aliyun_clb.go index 390f3e525..065ce9251 100644 --- a/pkg/core/deployer/providers/aliyun-clb/aliyun_clb.go +++ b/pkg/core/deployer/providers/aliyun-clb/aliyun_clb.go @@ -225,6 +225,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan d.logger.Info("no need to deploy clb listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, cloudLoadbalancerId, cloudListenerPort, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 diff --git a/pkg/core/deployer/providers/aliyun-ga/aliyun_ga.go b/pkg/core/deployer/providers/aliyun-ga/aliyun_ga.go index 2d1c12065..efbd44f4e 100644 --- a/pkg/core/deployer/providers/aliyun-ga/aliyun_ga.go +++ b/pkg/core/deployer/providers/aliyun-ga/aliyun_ga.go @@ -240,6 +240,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat d.logger.Info("no need to deploy ga listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, cloudListenerId, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 diff --git a/pkg/core/deployer/providers/baiducloud-appblb/baiducloud_appblb.go b/pkg/core/deployer/providers/baiducloud-appblb/baiducloud_appblb.go index 56872279e..ea9585c22 100644 --- a/pkg/core/deployer/providers/baiducloud-appblb/baiducloud_appblb.go +++ b/pkg/core/deployer/providers/baiducloud-appblb/baiducloud_appblb.go @@ -240,6 +240,7 @@ func (d *Deployer) updateHttpsListenerCertificate(ctx context.Context, cloudLoad d.logger.Info("no need to deploy appblb listener default certificate") return nil } + return d.updateHttpsListenerDefaultCertificate(ctx, cloudLoadbalancerId, &listenerInfo, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 diff --git a/pkg/core/deployer/providers/baiducloud-blb/baiducloud_blb.go b/pkg/core/deployer/providers/baiducloud-blb/baiducloud_blb.go index 34ef3254f..8fe4ca288 100644 --- a/pkg/core/deployer/providers/baiducloud-blb/baiducloud_blb.go +++ b/pkg/core/deployer/providers/baiducloud-blb/baiducloud_blb.go @@ -240,6 +240,7 @@ func (d *Deployer) updateHttpsListenerCertificate(ctx context.Context, cloudLoad d.logger.Info("no need to deploy blb listener default certificate") return nil } + return d.updateHttpsListenerDefaultCertificate(ctx, cloudLoadbalancerId, &listenerInfo, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 diff --git a/pkg/core/deployer/providers/byteplus-alb/byteplus_alb.go b/pkg/core/deployer/providers/byteplus-alb/byteplus_alb.go index f61b5fc4b..c14826d38 100644 --- a/pkg/core/deployer/providers/byteplus-alb/byteplus_alb.go +++ b/pkg/core/deployer/providers/byteplus-alb/byteplus_alb.go @@ -213,6 +213,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI d.logger.Info("no need to deploy alb listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, *describeListenerAttributesResp, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 @@ -252,7 +253,8 @@ func (d *Deployer) updateListenerSniCertificate(ctx context.Context, cloudListen CertCenterCertificateId: bp.String(cloudCertId), Action: bp.String("modify"), } - }), + }, + ), } modifyListenerAttributesResp, err := d.sdkClient.ModifyListenerAttributesWithContext(ctx, modifyListenerAttributesReq) d.logger.Debug("sdk request 'alb.ModifyListenerAttributes'", slog.Any("request", modifyListenerAttributesReq), slog.Any("response", modifyListenerAttributesResp)) diff --git a/pkg/core/deployer/providers/byteplus-cdn/byteplus_cdn.go b/pkg/core/deployer/providers/byteplus-cdn/byteplus_cdn.go index e0507f368..0ec105529 100644 --- a/pkg/core/deployer/providers/byteplus-cdn/byteplus_cdn.go +++ b/pkg/core/deployer/providers/byteplus-cdn/byteplus_cdn.go @@ -112,6 +112,9 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*Dep } domains = domainCandidates + if len(domains) == 0 { + return nil, fmt.Errorf("could not find any domains matched by wildcard") + } } else { domains = []string{d.config.Domain} } @@ -125,6 +128,9 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*Dep } domains = domainCandidates + if len(domains) == 0 { + return nil, fmt.Errorf("could not find any domains matched by certificate") + } } default: @@ -216,12 +222,6 @@ func (d *Deployer) getMatchedDomainsByCertId(ctx context.Context, cloudCertId st } } - if len(domains) == 0 { - if len(describeCertConfigResp.Result.SpecifiedCertConfig) == 0 { - return nil, fmt.Errorf("could not find any domains matched by certificate") - } - } - return domains, nil } diff --git a/pkg/core/deployer/providers/ucloud-ualb/ucloud_ualb.go b/pkg/core/deployer/providers/ucloud-ualb/ucloud_ualb.go index 18c7d1c90..55864c847 100644 --- a/pkg/core/deployer/providers/ucloud-ualb/ucloud_ualb.go +++ b/pkg/core/deployer/providers/ucloud-ualb/ucloud_ualb.go @@ -220,6 +220,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan d.logger.Info("no need to deploy alb listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, cloudLoadbalancerId, cloudListenerId, cloudCertId) } else { // 指定 SNI,需部署到扩展域名 @@ -227,6 +228,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan d.logger.Info("no need to deploy alb listener sni certificate") return nil } + return d.updateListenerSniCertificate(ctx, cloudLoadbalancerId, listenerInfo, cloudCertId) } } diff --git a/pkg/core/deployer/providers/volcengine-alb/volcengine_alb.go b/pkg/core/deployer/providers/volcengine-alb/volcengine_alb.go index cf3b76468..92108844e 100644 --- a/pkg/core/deployer/providers/volcengine-alb/volcengine_alb.go +++ b/pkg/core/deployer/providers/volcengine-alb/volcengine_alb.go @@ -216,8 +216,16 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI d.logger.Info("no need to deploy alb listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, *describeListenerAttributesResp, cloudCertId) } else { + if lo.SomeBy(describeListenerAttributesResp.DomainExtensions, func(domainExtension *vealb.DomainExtensionForDescribeListenerAttributesOutput) bool { + return ve.StringValue(domainExtension.Domain) == d.config.Domain && ve.StringValue(domainExtension.CertCenterCertificateId) == cloudCertId + }) { + d.logger.Info("no need to deploy alb listener sni certificate") + return nil + } + // 指定 SNI,需部署到扩展域名 return d.updateListenerSniCertificate(ctx, *describeListenerAttributesResp, cloudCertId) } @@ -247,7 +255,7 @@ func (d *Deployer) updateListenerSniCertificate(ctx context.Context, cloudListen ListenerId: cloudListenerInfo.ListenerId, DomainExtensions: lo.Map( lo.Filter(cloudListenerInfo.DomainExtensions, func(domain *vealb.DomainExtensionForDescribeListenerAttributesOutput, _ int) bool { - return *domain.Domain == d.config.Domain + return ve.StringValue(domain.Domain) == d.config.Domain }), func(domain *vealb.DomainExtensionForDescribeListenerAttributesOutput, _ int) *vealb.DomainExtensionForModifyListenerAttributesInput { return &vealb.DomainExtensionForModifyListenerAttributesInput{ @@ -257,7 +265,8 @@ func (d *Deployer) updateListenerSniCertificate(ctx context.Context, cloudListen CertCenterCertificateId: ve.String(cloudCertId), Action: ve.String("modify"), } - }), + }, + ), } modifyListenerAttributesResp, err := d.sdkClient.ModifyListenerAttributesWithContext(ctx, modifyListenerAttributesReq) d.logger.Debug("sdk request 'alb.ModifyListenerAttributes'", slog.Any("request", modifyListenerAttributesReq), slog.Any("response", modifyListenerAttributesResp)) diff --git a/pkg/core/deployer/providers/volcengine-cdn/volcengine_cdn.go b/pkg/core/deployer/providers/volcengine-cdn/volcengine_cdn.go index 01867d703..d47db5138 100644 --- a/pkg/core/deployer/providers/volcengine-cdn/volcengine_cdn.go +++ b/pkg/core/deployer/providers/volcengine-cdn/volcengine_cdn.go @@ -117,6 +117,9 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*Dep } domains = domainCandidates + if len(domains) == 0 { + return nil, fmt.Errorf("could not find any domains matched by wildcard") + } } else { domains = []string{d.config.Domain} } @@ -130,6 +133,9 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*Dep } domains = domainCandidates + if len(domains) == 0 { + return nil, fmt.Errorf("could not find any domains matched by certificate") + } } default: @@ -192,10 +198,6 @@ func (d *Deployer) getMatchedDomainsByWildcard(ctx context.Context, wildcardDoma listCdnDomainsPageSize++ } - if len(domains) == 0 { - return nil, fmt.Errorf("could not find any domains matched by wildcard") - } - return domains, nil } @@ -225,12 +227,6 @@ func (d *Deployer) getMatchedDomainsByCertId(ctx context.Context, cloudCertId st } } - if len(domains) == 0 { - if len(describeCertConfigResp.SpecifiedCertConfig) == 0 { - return nil, fmt.Errorf("could not find any domains matched by certificate") - } - } - return domains, nil } diff --git a/pkg/core/deployer/providers/volcengine-clb/volcengine_clb.go b/pkg/core/deployer/providers/volcengine-clb/volcengine_clb.go index 795f6b3ad..a8c33032a 100644 --- a/pkg/core/deployer/providers/volcengine-clb/volcengine_clb.go +++ b/pkg/core/deployer/providers/volcengine-clb/volcengine_clb.go @@ -218,8 +218,16 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI d.logger.Info("no need to deploy clb listener default certificate") return nil } + return d.updateListenerDefaultCertificate(ctx, cloudListenerId, cloudCertId) } else { + if lo.SomeBy(describeListenerAttributesResp.DomainExtensions, func(domainExtension *veclb.DomainExtensionForDescribeListenerAttributesOutput) bool { + return ve.StringValue(domainExtension.Domain) == d.config.Domain && ve.StringValue(domainExtension.CertCenterCertificateId) == cloudCertId + }) { + d.logger.Info("no need to deploy clb listener sni certificate") + return nil + } + // 指定 SNI,需部署到扩展域名 return d.updateListenerSniCertificate(ctx, describeListenerAttributesResp, cloudCertId) } @@ -248,9 +256,6 @@ func (d *Deployer) updateListenerSniCertificate(ctx context.Context, cloudListen }) if domainExtension == nil { return fmt.Errorf("could not find clb listener domain extension '%s' for listener '%s'", d.config.Domain, ve.StringValue(cloudListenerInfo.ListenerId)) - } else if ve.StringValue(domainExtension.CertCenterCertificateId) == cloudCertId { - d.logger.Info("no need to deploy clb listener extension domain certificate") - return nil } // 修改指定监听器的扩展域名证书