diff --git a/internal/deployer/tencent_clb.go b/internal/deployer/tencent_clb.go index 4da6c34c..ba97e840 100644 --- a/internal/deployer/tencent_clb.go +++ b/internal/deployer/tencent_clb.go @@ -85,13 +85,13 @@ func (d *TencentCLBDeployer) deploy(certId string) error { cpf := profile.NewClientProfile() cpf.HttpProfile.Endpoint = "ssl.tencentcloudapi.com" // 实例化要请求产品的client对象,clientProfile是可选的 - client, _ := ssl.NewClient(d.credential, "", cpf) + client, _ := ssl.NewClient(d.credential, getDeployString(d.option.DeployConfig, "region"), cpf) // 实例化一个请求对象,每个接口都会对应一个request对象 request := ssl.NewDeployCertificateInstanceRequest() request.CertificateId = common.StringPtr(certId) - request.ResourceType = common.StringPtr("cdn") + request.ResourceType = common.StringPtr("clb") request.Status = common.Int64Ptr(1) clbId := getDeployString(d.option.DeployConfig, "clbId") diff --git a/ui/src/components/certimate/DeployToTencentCLB.tsx b/ui/src/components/certimate/DeployToTencentCLB.tsx index 1a7a2eb6..ff50b8fe 100644 --- a/ui/src/components/certimate/DeployToTencentCLB.tsx +++ b/ui/src/components/certimate/DeployToTencentCLB.tsx @@ -61,6 +61,21 @@ const DeployToTencentCLB = () => { } }, [data]); + useEffect(() => { + const regionResp = regionSchema.safeParse(data.config?.region); + if (!regionResp.success) { + setError({ + ...error, + region: JSON.parse(regionResp.error.message)[0].message, + }); + } else { + setError({ + ...error, + region: "", + }); + } + }, []); + useEffect(() => { if (!data.id) { @@ -70,11 +85,16 @@ const DeployToTencentCLB = () => { lsnId: "", clbId: "", domain: "", + region: "", }, }); } }, []); + const regionSchema = z.string().regex(/^ap-[a-z]+$/, { + message: t("domain.deployment.form.clb_region.placeholder"), + }); + const domainSchema = z.string().regex(/^$|^(?:\*\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/, { message: t("common.errmsg.domain_invalid"), }); @@ -89,6 +109,40 @@ const DeployToTencentCLB = () => { return (
+
+ + { + const temp = e.target.value; + + const resp = regionSchema.safeParse(temp); + if (!resp.success) { + setError({ + ...error, + region: JSON.parse(resp.error.message)[0].message, + }); + } else { + setError({ + ...error, + region: "", + }); + } + + const newData = produce(data, (draft) => { + if (!draft.config) { + draft.config = {}; + } + draft.config.region = temp; + }); + setDeploy(newData); + }} + /> +
{error?.region}
+
+