mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-19 09:51:55 +08:00
fix: #834
This commit is contained in:
parent
3162673b9d
commit
0948291a9e
@ -5,10 +5,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/certimate-go/certimate/pkg/core"
|
"github.com/certimate-go/certimate/pkg/core"
|
||||||
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/ctcccloud-ao"
|
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/ctcccloud-ao"
|
||||||
ctyunao "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/ao"
|
ctyunao "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/ao"
|
||||||
|
xslices "github.com/certimate-go/certimate/pkg/utils/slices"
|
||||||
xtypes "github.com/certimate-go/certimate/pkg/utils/types"
|
xtypes "github.com/certimate-go/certimate/pkg/utils/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
|||||||
// REF: https://eop.ctyun.cn/ebp/ctapiDocument/search?sid=113&api=13412&data=174&isNormal=1&vid=167
|
// REF: https://eop.ctyun.cn/ebp/ctapiDocument/search?sid=113&api=13412&data=174&isNormal=1&vid=167
|
||||||
getDomainConfigReq := &ctyunao.GetDomainConfigRequest{
|
getDomainConfigReq := &ctyunao.GetDomainConfigRequest{
|
||||||
Domain: xtypes.ToPtr(d.config.Domain),
|
Domain: xtypes.ToPtr(d.config.Domain),
|
||||||
|
ProductCode: xtypes.ToPtr("020"),
|
||||||
}
|
}
|
||||||
getDomainConfigResp, err := d.sdkClient.GetDomainConfig(getDomainConfigReq)
|
getDomainConfigResp, err := d.sdkClient.GetDomainConfig(getDomainConfigReq)
|
||||||
d.logger.Debug("sdk request 'cdn.GetDomainConfig'", slog.Any("request", getDomainConfigReq), slog.Any("response", getDomainConfigResp))
|
d.logger.Debug("sdk request 'cdn.GetDomainConfig'", slog.Any("request", getDomainConfigReq), slog.Any("response", getDomainConfigResp))
|
||||||
@ -93,7 +96,17 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
|||||||
modifyDomainConfigReq := &ctyunao.ModifyDomainConfigRequest{
|
modifyDomainConfigReq := &ctyunao.ModifyDomainConfigRequest{
|
||||||
Domain: xtypes.ToPtr(d.config.Domain),
|
Domain: xtypes.ToPtr(d.config.Domain),
|
||||||
ProductCode: xtypes.ToPtr(getDomainConfigResp.ReturnObj.ProductCode),
|
ProductCode: xtypes.ToPtr(getDomainConfigResp.ReturnObj.ProductCode),
|
||||||
Origin: getDomainConfigResp.ReturnObj.Origin,
|
Origin: xslices.Map(getDomainConfigResp.ReturnObj.Origin, func(item *ctyunao.DomainOriginConfigWithWeight) *ctyunao.DomainOriginConfig {
|
||||||
|
weight := item.Weight
|
||||||
|
if weight == 0 {
|
||||||
|
weight = 1
|
||||||
|
}
|
||||||
|
return &ctyunao.DomainOriginConfig{
|
||||||
|
Origin: item.Origin,
|
||||||
|
Role: item.Role,
|
||||||
|
Weight: strconv.Itoa(int(weight)),
|
||||||
|
}
|
||||||
|
}),
|
||||||
HttpsStatus: xtypes.ToPtr("on"),
|
HttpsStatus: xtypes.ToPtr("on"),
|
||||||
CertName: xtypes.ToPtr(upres.CertName),
|
CertName: xtypes.ToPtr(upres.CertName),
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ type GetDomainConfigResponse struct {
|
|||||||
Status int32 `json:"status"`
|
Status int32 `json:"status"`
|
||||||
AreaScope int32 `json:"area_scope"`
|
AreaScope int32 `json:"area_scope"`
|
||||||
Cname string `json:"cname"`
|
Cname string `json:"cname"`
|
||||||
Origin []*DomainOriginConfig `json:"origin,omitempty"`
|
Origin []*DomainOriginConfigWithWeight `json:"origin,omitempty"`
|
||||||
HttpsStatus string `json:"https_status"`
|
HttpsStatus string `json:"https_status"`
|
||||||
HttpsBasic *DomainHttpsBasicConfig `json:"https_basic,omitempty"`
|
HttpsBasic *DomainHttpsBasicConfig `json:"https_basic,omitempty"`
|
||||||
CertName string `json:"cert_name"`
|
CertName string `json:"cert_name"`
|
||||||
|
@ -90,6 +90,12 @@ type CertDetail struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DomainOriginConfig struct {
|
type DomainOriginConfig struct {
|
||||||
|
Origin string `json:"origin"`
|
||||||
|
Role string `json:"role"`
|
||||||
|
Weight string `json:"weight"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DomainOriginConfigWithWeight struct {
|
||||||
Origin string `json:"origin"`
|
Origin string `json:"origin"`
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
Weight int32 `json:"weight"`
|
Weight int32 `json:"weight"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user