diff --git a/internal/deployer/aliyun_alb.go b/internal/deployer/aliyun_alb.go index 4b0e3a31..2e05320e 100644 --- a/internal/deployer/aliyun_alb.go +++ b/internal/deployer/aliyun_alb.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "strings" aliyunAlb "github.com/alibabacloud-go/alb-20200616/v2/client" aliyunOpen "github.com/alibabacloud-go/darabonba-openapi/v2/client" @@ -39,10 +40,21 @@ func NewAliyunALBDeployer(option *DeployerOption) (Deployer, error) { return nil, xerrors.Wrap(err, "failed to create sdk client") } + aliCasRegion := option.DeployConfig.GetConfigAsString("region") + if aliCasRegion != "" { + // 阿里云 CAS 服务接入点是独立于 ALB 服务的 + // 国内版接入点:华东一杭州 + // 国际版接入点:亚太东南一新加坡 + if !strings.HasPrefix(aliCasRegion, "cn-") { + aliCasRegion = "ap-southeast-1" + } else { + aliCasRegion = "cn-hangzhou" + } + } uploader, err := uploaderAliyunCas.New(&uploaderAliyunCas.AliyunCASUploaderConfig{ AccessKeyId: access.AccessKeyId, AccessKeySecret: access.AccessKeySecret, - Region: "", // TODO: 暂时传空,但仅支持阿里云国内版、不支持国际版,后续需要重新设计表单以区分国内国际 + Region: aliCasRegion, }) if err != nil { return nil, xerrors.Wrap(err, "failed to create ssl uploader") diff --git a/internal/deployer/aliyun_nlb.go b/internal/deployer/aliyun_nlb.go index 866ea1f3..bbaddd7b 100644 --- a/internal/deployer/aliyun_nlb.go +++ b/internal/deployer/aliyun_nlb.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "strings" aliyunOpen "github.com/alibabacloud-go/darabonba-openapi/v2/client" aliyunNlb "github.com/alibabacloud-go/nlb-20220430/v2/client" @@ -39,10 +40,21 @@ func NewAliyunNLBDeployer(option *DeployerOption) (Deployer, error) { return nil, xerrors.Wrap(err, "failed to create sdk client") } + aliCasRegion := option.DeployConfig.GetConfigAsString("region") + if aliCasRegion != "" { + // 阿里云 CAS 服务接入点是独立于 NLB 服务的 + // 国内版接入点:华东一杭州 + // 国际版接入点:亚太东南一新加坡 + if !strings.HasPrefix(aliCasRegion, "cn-") { + aliCasRegion = "ap-southeast-1" + } else { + aliCasRegion = "cn-hangzhou" + } + } uploader, err := uploaderAliyunCas.New(&uploaderAliyunCas.AliyunCASUploaderConfig{ AccessKeyId: access.AccessKeyId, AccessKeySecret: access.AccessKeySecret, - Region: "", // TODO: 暂时传空,但仅支持阿里云国内版、不支持国际版,后续需要重新设计表单以区分国内国际 + Region: aliCasRegion, }) if err != nil { return nil, xerrors.Wrap(err, "failed to create ssl uploader") diff --git a/internal/deployer/tencent_clb.go b/internal/deployer/tencent_clb.go index 0a0c4b82..aac5137e 100644 --- a/internal/deployer/tencent_clb.go +++ b/internal/deployer/tencent_clb.go @@ -70,8 +70,6 @@ func (d *TencentCLBDeployer) GetInfos() []string { } func (d *TencentCLBDeployer) Deploy(ctx context.Context) error { - // TODO: 直接部署方式 - switch d.option.DeployConfig.GetConfigAsString("resourceType") { case "ssl-deploy": // 通过 SSL 服务部署到云资源实例