diff --git a/pkg/core/deployer/providers/aliyun-alb/aliyun_alb.go b/pkg/core/deployer/providers/aliyun-alb/aliyun_alb.go index eb65e254e..d00352721 100644 --- a/pkg/core/deployer/providers/aliyun-alb/aliyun_alb.go +++ b/pkg/core/deployer/providers/aliyun-alb/aliyun_alb.go @@ -20,6 +20,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcert "github.com/certimate-go/certimate/pkg/utils/cert" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" xwait "github.com/certimate-go/certimate/pkg/utils/wait" ) @@ -78,9 +79,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-apigw/aliyun_apigw.go b/pkg/core/deployer/providers/aliyun-apigw/aliyun_apigw.go index 2ecea8545..71699f4ba 100644 --- a/pkg/core/deployer/providers/aliyun-apigw/aliyun_apigw.go +++ b/pkg/core/deployer/providers/aliyun-apigw/aliyun_apigw.go @@ -19,6 +19,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -78,9 +79,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-cdn/aliyun_cdn.go b/pkg/core/deployer/providers/aliyun-cdn/aliyun_cdn.go index da44f292c..08e13952c 100644 --- a/pkg/core/deployer/providers/aliyun-cdn/aliyun_cdn.go +++ b/pkg/core/deployer/providers/aliyun-cdn/aliyun_cdn.go @@ -18,6 +18,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -64,9 +65,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-dcdn/aliyun_dcdn.go b/pkg/core/deployer/providers/aliyun-dcdn/aliyun_dcdn.go index d70945465..7486065dc 100644 --- a/pkg/core/deployer/providers/aliyun-dcdn/aliyun_dcdn.go +++ b/pkg/core/deployer/providers/aliyun-dcdn/aliyun_dcdn.go @@ -18,6 +18,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -64,9 +65,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-ddospro/aliyun_ddospro.go b/pkg/core/deployer/providers/aliyun-ddospro/aliyun_ddospro.go index 3869247dd..a7b9f9100 100644 --- a/pkg/core/deployer/providers/aliyun-ddospro/aliyun_ddospro.go +++ b/pkg/core/deployer/providers/aliyun-ddospro/aliyun_ddospro.go @@ -17,6 +17,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -63,9 +64,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-esa-saas/aliyun_esasaas.go b/pkg/core/deployer/providers/aliyun-esa-saas/aliyun_esasaas.go index ed6bd6409..2497d2401 100644 --- a/pkg/core/deployer/providers/aliyun-esa-saas/aliyun_esasaas.go +++ b/pkg/core/deployer/providers/aliyun-esa-saas/aliyun_esasaas.go @@ -18,6 +18,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -66,9 +67,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-esa/aliyun_esa.go b/pkg/core/deployer/providers/aliyun-esa/aliyun_esa.go index 93b09f5e0..88731a30f 100644 --- a/pkg/core/deployer/providers/aliyun-esa/aliyun_esa.go +++ b/pkg/core/deployer/providers/aliyun-esa/aliyun_esa.go @@ -5,7 +5,6 @@ import ( "fmt" "log/slog" "strconv" - "strings" aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client" "github.com/alibabacloud-go/tea/dara" @@ -16,6 +15,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -59,9 +59,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-nlb/aliyun_nlb.go b/pkg/core/deployer/providers/aliyun-nlb/aliyun_nlb.go index 9cd6d8303..1bc3fb192 100644 --- a/pkg/core/deployer/providers/aliyun-nlb/aliyun_nlb.go +++ b/pkg/core/deployer/providers/aliyun-nlb/aliyun_nlb.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "log/slog" - "strings" aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client" "github.com/alibabacloud-go/tea/dara" @@ -16,6 +15,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -65,9 +65,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-oss/aliyun_oss.go b/pkg/core/deployer/providers/aliyun-oss/aliyun_oss.go index f2571075e..70bb514fd 100644 --- a/pkg/core/deployer/providers/aliyun-oss/aliyun_oss.go +++ b/pkg/core/deployer/providers/aliyun-oss/aliyun_oss.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log/slog" - "strings" "github.com/alibabacloud-go/tea/tea" "github.com/samber/lo" @@ -12,6 +11,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" osssdk "github.com/certimate-go/certimate/pkg/sdk3rd/alibabacloud/oss" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -57,9 +57,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-vod/aliyun_vod.go b/pkg/core/deployer/providers/aliyun-vod/aliyun_vod.go index 1e60c1108..570699fbd 100644 --- a/pkg/core/deployer/providers/aliyun-vod/aliyun_vod.go +++ b/pkg/core/deployer/providers/aliyun-vod/aliyun_vod.go @@ -18,6 +18,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -64,9 +65,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/aliyun-waf/aliyun_waf.go b/pkg/core/deployer/providers/aliyun-waf/aliyun_waf.go index 5140ddd0b..3c2cdd292 100644 --- a/pkg/core/deployer/providers/aliyun-waf/aliyun_waf.go +++ b/pkg/core/deployer/providers/aliyun-waf/aliyun_waf.go @@ -16,6 +16,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas" + xalibabacloud "github.com/certimate-go/certimate/pkg/utils/third-party/alibabacloud" ) type ( @@ -75,9 +76,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { AccessKeyId: config.AccessKeyId, AccessKeySecret: config.AccessKeySecret, ResourceGroupId: config.ResourceGroupId, - Region: lo. - If(config.Region == "" || strings.HasPrefix(config.Region, "cn-"), "cn-hangzhou"). - Else("ap-southeast-1"), + Region: lo.Ternary(xalibabacloud.IsIntlRegion(config.Region), "ap-southeast-1", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-cdn/tencentcloud_cdn.go b/pkg/core/deployer/providers/tencentcloud-cdn/tencentcloud_cdn.go index 50f356d35..f04fc26f3 100644 --- a/pkg/core/deployer/providers/tencentcloud-cdn/tencentcloud_cdn.go +++ b/pkg/core/deployer/providers/tencentcloud-cdn/tencentcloud_cdn.go @@ -16,6 +16,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -62,9 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-clb/tencentcloud_clb.go b/pkg/core/deployer/providers/tencentcloud-clb/tencentcloud_clb.go index 6cf7e9e2c..888a3a1f0 100644 --- a/pkg/core/deployer/providers/tencentcloud-clb/tencentcloud_clb.go +++ b/pkg/core/deployer/providers/tencentcloud-clb/tencentcloud_clb.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "log/slog" - "strings" "time" "github.com/samber/lo" @@ -16,6 +15,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" xwait "github.com/certimate-go/certimate/pkg/utils/wait" ) @@ -71,9 +71,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-css/tencentcloud_css.go b/pkg/core/deployer/providers/tencentcloud-css/tencentcloud_css.go index 3d8c8b447..708c0f1b8 100644 --- a/pkg/core/deployer/providers/tencentcloud-css/tencentcloud_css.go +++ b/pkg/core/deployer/providers/tencentcloud-css/tencentcloud_css.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log/slog" - "strings" "github.com/samber/lo" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" @@ -15,6 +14,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -61,9 +61,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-ecdn/tencentcloud_ecdn.go b/pkg/core/deployer/providers/tencentcloud-ecdn/tencentcloud_ecdn.go index ea0858d54..41e044d02 100644 --- a/pkg/core/deployer/providers/tencentcloud-ecdn/tencentcloud_ecdn.go +++ b/pkg/core/deployer/providers/tencentcloud-ecdn/tencentcloud_ecdn.go @@ -16,6 +16,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -62,9 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-eo/tencentcloud_eo.go b/pkg/core/deployer/providers/tencentcloud-eo/tencentcloud_eo.go index 1a2a6f4a2..c1394c56c 100644 --- a/pkg/core/deployer/providers/tencentcloud-eo/tencentcloud_eo.go +++ b/pkg/core/deployer/providers/tencentcloud-eo/tencentcloud_eo.go @@ -20,6 +20,7 @@ import ( xcert "github.com/certimate-go/certimate/pkg/utils/cert" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" xcertkey "github.com/certimate-go/certimate/pkg/utils/cert/key" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -70,9 +71,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-ga2/tencentcloud_ga2.go b/pkg/core/deployer/providers/tencentcloud-ga2/tencentcloud_ga2.go index 5dcfc9bc4..c561cf962 100644 --- a/pkg/core/deployer/providers/tencentcloud-ga2/tencentcloud_ga2.go +++ b/pkg/core/deployer/providers/tencentcloud-ga2/tencentcloud_ga2.go @@ -17,6 +17,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" xcert "github.com/certimate-go/certimate/pkg/utils/cert" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -71,9 +72,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-scf/tencentcloud_scf.go b/pkg/core/deployer/providers/tencentcloud-scf/tencentcloud_scf.go index d9ed258cb..a25dbb3bf 100644 --- a/pkg/core/deployer/providers/tencentcloud-scf/tencentcloud_scf.go +++ b/pkg/core/deployer/providers/tencentcloud-scf/tencentcloud_scf.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "log/slog" - "strings" "github.com/samber/lo" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" @@ -16,6 +15,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -64,9 +64,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-vod/tencentcloud_vod.go b/pkg/core/deployer/providers/tencentcloud-vod/tencentcloud_vod.go index 3f7b59336..be386624d 100644 --- a/pkg/core/deployer/providers/tencentcloud-vod/tencentcloud_vod.go +++ b/pkg/core/deployer/providers/tencentcloud-vod/tencentcloud_vod.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "log/slog" - "strings" "github.com/samber/lo" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" @@ -15,6 +14,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -63,9 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/core/deployer/providers/tencentcloud-waf/tencentcloud_waf.go b/pkg/core/deployer/providers/tencentcloud-waf/tencentcloud_waf.go index 16569464d..928afcaca 100644 --- a/pkg/core/deployer/providers/tencentcloud-waf/tencentcloud_waf.go +++ b/pkg/core/deployer/providers/tencentcloud-waf/tencentcloud_waf.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log/slog" - "strings" "github.com/samber/lo" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" @@ -14,6 +13,7 @@ import ( "github.com/certimate-go/certimate/pkg/core" cmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl" + xtencentcloud "github.com/certimate-go/certimate/pkg/utils/third-party/tencentcloud" ) type ( @@ -63,9 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) { SecretId: config.SecretId, SecretKey: config.SecretKey, ProjectId: config.ProjectId, - Endpoint: lo. - If(strings.HasSuffix(config.Endpoint, "intl.tencentcloudapi.com"), "ssl.intl.tencentcloudapi.com"). // 国际站使用独立的接口端点 - Else(""), + Endpoint: lo.Ternary(xtencentcloud.IsIntlAPIEndpoint(config.Endpoint), "ssl.intl.tencentcloudapi.com", ""), }) if err != nil { return nil, fmt.Errorf("could not create certmgr: %w", err) diff --git a/pkg/sdk3rd-forked b/pkg/sdk3rd-forked index 41a6ee533..a0af860d1 160000 --- a/pkg/sdk3rd-forked +++ b/pkg/sdk3rd-forked @@ -1 +1 @@ -Subproject commit 41a6ee5338f34c0d7cf80df56380a6b5552bafab +Subproject commit a0af860d1ffa9416457790251fd8175dd16a0d4c diff --git a/pkg/utils/third-party/alibabacloud/intl.go b/pkg/utils/third-party/alibabacloud/intl.go new file mode 100644 index 000000000..df1f1f060 --- /dev/null +++ b/pkg/utils/third-party/alibabacloud/intl.go @@ -0,0 +1,11 @@ +package alibabacloud + +import ( + "strings" +) + +// 判断地域是否属于阿里云国际版。 +func IsIntlRegion(region string) bool { + region = strings.TrimSpace(region) + return region != "" && !strings.HasPrefix(region, "cn-") +} diff --git a/pkg/utils/third-party/tencentcloud/intl.go b/pkg/utils/third-party/tencentcloud/intl.go new file mode 100644 index 000000000..6ff010388 --- /dev/null +++ b/pkg/utils/third-party/tencentcloud/intl.go @@ -0,0 +1,15 @@ +package tencentcloud + +import ( + "strings" +) + +// 判断 API 接口端点是否属于腾讯云国际版。 +func IsIntlAPIEndpoint(endpoint string) bool { + return strings.Contains(endpoint, "intl.tencentcloudapi.com") +} + +// 判断 EdgeOne 接口端点是否属于腾讯云国际版。 +func IsIntlEdgeOneEndpoint(endpoint string) bool { + return strings.Contains(endpoint, "edgeone.ai") +}