mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
feat(provider): new deployment provider: byteplus certcenter
This commit is contained in:
@@ -38,6 +38,7 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/service/iam v1.53.10
|
||||
github.com/aws/aws-sdk-go-v2/service/lightsail v1.54.0
|
||||
github.com/baidubce/bce-sdk-go v0.9.266
|
||||
github.com/byteplus-sdk/byteplus-go-sdk-v2 v1.0.65
|
||||
github.com/byteplus-sdk/byteplus-sdk-golang v1.0.65
|
||||
github.com/go-acme/lego/v5 v5.1.0
|
||||
github.com/go-cmd/cmd v1.4.3
|
||||
|
||||
@@ -257,6 +257,9 @@ github.com/boombuler/barcode v1.1.0 h1:ChaYjBR63fr4LFyGn8E8nt7dBSt3MiU3zMOZqFvVk
|
||||
github.com/boombuler/barcode v1.1.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY=
|
||||
github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE=
|
||||
github.com/byteplus-sdk/byteplus-go-sdk-v2 v1.0.65 h1:6qCTwt4bzF7ofeASf+Ja4BDqhGD39uBThQZWFgUbnX4=
|
||||
github.com/byteplus-sdk/byteplus-go-sdk-v2 v1.0.65/go.mod h1:eqR3bDX3XtdPBcB9vERznOyi0MAcAI1GFAdcRspNMBU=
|
||||
github.com/byteplus-sdk/byteplus-sdk-golang v1.0.16/go.mod h1:7iCaE+dR9EycrJU0GQyMhptbInLbQhsKXiDKDjNi8Vs=
|
||||
github.com/byteplus-sdk/byteplus-sdk-golang v1.0.65 h1:hmRsVDVU5gP/UdM/PIXTjYRAHWspe8+wUOlPsFJ9Ppg=
|
||||
github.com/byteplus-sdk/byteplus-sdk-golang v1.0.65/go.mod h1:CIL/T2dxgbIA79os+wl0Fq0vCbADTZNIddV6PNYB6DY=
|
||||
github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package deployers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/certimate-go/certimate/internal/domain"
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
bytepluscertcenter "github.com/certimate-go/certimate/pkg/core/deployer/providers/byteplus-certcenter"
|
||||
xmaps "github.com/certimate-go/certimate/pkg/utils/maps"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Registries.MustRegister(domain.DeploymentProviderTypeBytePlusCertCenter, func(options *ProviderFactoryOptions) (core.Deployer, error) {
|
||||
credentials := domain.AccessConfigForBytePlus{}
|
||||
if err := xmaps.Populate(options.ProviderAccessConfig, &credentials); err != nil {
|
||||
return nil, fmt.Errorf("failed to populate provider access config: %w", err)
|
||||
}
|
||||
|
||||
provider, err := bytepluscertcenter.NewDeployer(&bytepluscertcenter.DeployerConfig{
|
||||
AccessKey: credentials.AccessKey,
|
||||
SecretKey: credentials.SecretKey,
|
||||
ProjectName: credentials.ProjectName,
|
||||
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
|
||||
})
|
||||
return provider, err
|
||||
})
|
||||
}
|
||||
@@ -339,6 +339,7 @@ const (
|
||||
DeploymentProviderTypeBaotaWAFConsole = DeploymentProviderType(AccessProviderTypeBaotaWAF + "-console")
|
||||
DeploymentProviderTypeBunnyCDN = DeploymentProviderType(AccessProviderTypeBunny + "-cdn")
|
||||
DeploymentProviderTypeBytePlusCDN = DeploymentProviderType(AccessProviderTypeBytePlus + "-cdn")
|
||||
DeploymentProviderTypeBytePlusCertCenter = DeploymentProviderType(AccessProviderTypeBytePlus + "-certcenter")
|
||||
DeploymentProviderTypeCacheFly = DeploymentProviderType(AccessProviderTypeCacheFly)
|
||||
DeploymentProviderTypeCdnfly = DeploymentProviderType(AccessProviderTypeCdnfly)
|
||||
DeploymentProviderTypeCPanel = DeploymentProviderType(AccessProviderTypeCPanel)
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
bytepluscdn "github.com/byteplus-sdk/byteplus-sdk-golang/service/cdn"
|
||||
bpcdn "github.com/byteplus-sdk/byteplus-sdk-golang/service/cdn"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
@@ -26,7 +26,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *bytepluscdn.CDN
|
||||
sdkClient *bpcdn.CDN
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -36,7 +36,7 @@ func NewCertmgr(config *CertmgrConfig) (*Certmgr, error) {
|
||||
return nil, fmt.Errorf("the configuration of the certmgr provider is nil")
|
||||
}
|
||||
|
||||
client := bytepluscdn.NewInstance()
|
||||
client := bpcdn.NewInstance()
|
||||
client.Client.SetAccessKey(config.AccessKey)
|
||||
client.Client.SetSecretKey(config.SecretKey)
|
||||
|
||||
@@ -73,10 +73,10 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
listCertInfoReq := &bytepluscdn.ListCertInfoRequest{
|
||||
PageNum: bytepluscdn.GetInt64Ptr(int64(listCertInfoPageNum)),
|
||||
PageSize: bytepluscdn.GetInt64Ptr(int64(listCertInfoPageSize)),
|
||||
Source: bytepluscdn.GetStrPtr("cert_center"),
|
||||
listCertInfoReq := &bpcdn.ListCertInfoRequest{
|
||||
PageNum: bpcdn.GetInt64Ptr(int64(listCertInfoPageNum)),
|
||||
PageSize: bpcdn.GetInt64Ptr(int64(listCertInfoPageSize)),
|
||||
Source: bpcdn.GetStrPtr("cert_center"),
|
||||
}
|
||||
listCertInfoResp, err := c.sdkClient.ListCertInfo(listCertInfoReq)
|
||||
c.logger.Debug("sdk request 'cdn.ListCertInfo'", slog.Any("request", listCertInfoReq), slog.Any("response", listCertInfoResp))
|
||||
@@ -117,11 +117,11 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 上传新证书
|
||||
// REF: https://docs.byteplus.com/en/docs/byteplus-cdn/reference-addcertificate
|
||||
addCertificateReq := &bytepluscdn.AddCertificateRequest{
|
||||
addCertificateReq := &bpcdn.AddCertificateRequest{
|
||||
Certificate: certPEM,
|
||||
PrivateKey: privkeyPEM,
|
||||
Source: bytepluscdn.GetStrPtr("cert_center"),
|
||||
Desc: bytepluscdn.GetStrPtr(certName),
|
||||
Source: bpcdn.GetStrPtr("cert_center"),
|
||||
Desc: bpcdn.GetStrPtr(certName),
|
||||
}
|
||||
addCertificateResp, err := c.sdkClient.AddCertificate(addCertificateReq)
|
||||
c.logger.Debug("sdk request 'cdn.AddCertificate'", slog.Any("request", addCertificateReq), slog.Any("response", addCertificateResp))
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package bytepluscertcenter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
bp "github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus"
|
||||
bpsesion "github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/session"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
bpcertificateservice "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/byteplus-sdk/byteplus-go-sdk-v2/service/certificateservice"
|
||||
)
|
||||
|
||||
type CertmgrConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus 项目名称。
|
||||
ProjectName string `json:"projectName,omitempty"`
|
||||
// BytePlus 地域。
|
||||
Region string `json:"region"`
|
||||
}
|
||||
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *bpcertificateservice.CERTIFICATESERVICE
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
|
||||
func NewCertmgr(config *CertmgrConfig) (*Certmgr, error) {
|
||||
if config == nil {
|
||||
return nil, fmt.Errorf("the configuration of the certmgr provider is nil")
|
||||
}
|
||||
|
||||
client, err := createSDKClient(config.AccessKey, config.SecretKey, config.Region)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
return &Certmgr{
|
||||
config: config,
|
||||
logger: slog.Default(),
|
||||
sdkClient: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Certmgr) SetLogger(logger *slog.Logger) {
|
||||
if logger == nil {
|
||||
c.logger = slog.New(slog.DiscardHandler)
|
||||
} else {
|
||||
c.logger = logger
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*certmgr.UploadResult, error) {
|
||||
// 上传证书
|
||||
// REF: https://docs.byteplus.com/en/docs/byteplus-certificate-center/reference-uploadcertificate
|
||||
uploadCertificateReq := &bpcertificateservice.UploadCertificateInput{
|
||||
ProjectName: lo.EmptyableToPtr(c.config.ProjectName),
|
||||
CertificateInfo: &bpcertificateservice.CertificateInfoForUploadCertificateInput{
|
||||
CertificateChain: bp.String(certPEM),
|
||||
PrivateKey: bp.String(privkeyPEM),
|
||||
},
|
||||
Repeatable: bp.Bool(false),
|
||||
}
|
||||
uploadCertificateResp, err := c.sdkClient.UploadCertificateWithContext(ctx, uploadCertificateReq)
|
||||
c.logger.Debug("sdk request 'certificateservice.UploadCertificate'", slog.Any("request", uploadCertificateReq), slog.Any("response", uploadCertificateResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'certificateservice.UploadCertificate': %w", err)
|
||||
}
|
||||
|
||||
var sslId string
|
||||
if uploadCertificateResp.InstanceId != nil && *uploadCertificateResp.InstanceId != "" {
|
||||
sslId = *uploadCertificateResp.InstanceId
|
||||
}
|
||||
if uploadCertificateResp.RepeatId != nil && *uploadCertificateResp.RepeatId != "" {
|
||||
sslId = *uploadCertificateResp.RepeatId
|
||||
}
|
||||
|
||||
if sslId == "" {
|
||||
return nil, fmt.Errorf("received empty certificate id, both `InstanceId` and `RepeatId` are empty")
|
||||
}
|
||||
|
||||
return &certmgr.UploadResult{
|
||||
CertId: sslId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, privkeyPEM string) (*certmgr.ReplaceResult, error) {
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKey, secretKey, region string) (*bpcertificateservice.CERTIFICATESERVICE, error) {
|
||||
if region == "" {
|
||||
region = "ap-singapore-1" // 证书中心默认区域:新加坡
|
||||
}
|
||||
|
||||
config := bp.NewConfig().
|
||||
WithAkSk(accessKey, secretKey).
|
||||
WithRegion(region)
|
||||
|
||||
session, err := bpsesion.NewSession(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := bpcertificateservice.New(session, config)
|
||||
return client, nil
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package bytepluscertcenter_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/internal/tester"
|
||||
impl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-certcenter"
|
||||
)
|
||||
|
||||
var (
|
||||
fp = tester.Args("BYTEPLUSCERTCENTER_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
)
|
||||
|
||||
func init() {
|
||||
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
|
||||
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
|
||||
fp.DefineString(&fAccessKey, "ACCESSKEY")
|
||||
fp.DefineString(&fSecretKey, "SECRETKEY")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./byteplus_certcenter_test.go -args \
|
||||
--BYTEPLUSCERTCENTER_TESTCERTPATH="/path/to/your-test-cert.pem" \
|
||||
--BYTEPLUSCERTCENTER_TESTKEYPATH="/path/to/your-test-key.pem" \
|
||||
--BYTEPLUSCERTCENTER_ACCESSKEY="your-access-key" \
|
||||
--BYTEPLUSCERTCENTER_SECRETKEY="your-secret-key"
|
||||
*/
|
||||
func TestProvider(t *testing.T) {
|
||||
fp.Parse()
|
||||
|
||||
t.Run("Upload", func(t *testing.T) {
|
||||
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
tester.TestUpload(t, provider, tester.TestUploadArgs{CertPath: fTestCertPath, KeyPath: fTestKeyPath})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package bytepluscertcenter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-certcenter"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus 项目名称。
|
||||
ProjectName string `json:"projectName,omitempty"`
|
||||
// BytePlus 地域。
|
||||
Region string `json:"region"`
|
||||
}
|
||||
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
|
||||
func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
if config == nil {
|
||||
return nil, fmt.Errorf("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
ProjectName: config.ProjectName,
|
||||
Region: config.Region,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create certmgr: %w", err)
|
||||
}
|
||||
|
||||
return &Deployer{
|
||||
config: config,
|
||||
logger: slog.Default(),
|
||||
sdkCertmgr: pcertmgr,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Deployer) SetLogger(logger *slog.Logger) {
|
||||
if logger == nil {
|
||||
d.logger = slog.New(slog.DiscardHandler)
|
||||
} else {
|
||||
d.logger = logger
|
||||
}
|
||||
|
||||
d.sdkCertmgr.SetLogger(logger)
|
||||
}
|
||||
|
||||
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
|
||||
// 上传证书
|
||||
upres, err := d.sdkCertmgr.Upload(ctx, certPEM, privkeyPEM)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to upload certificate file: %w", err)
|
||||
} else {
|
||||
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
|
||||
}
|
||||
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package certificateservice
|
||||
|
||||
import (
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/byteplusutil"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/request"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/response"
|
||||
)
|
||||
|
||||
const opUploadCertificate = "UploadCertificate"
|
||||
|
||||
func (c *CERTIFICATESERVICE) UploadCertificateRequest(input *UploadCertificateInput) (req *request.Request, output *UploadCertificateOutput) {
|
||||
op := &request.Operation{
|
||||
Name: opUploadCertificate,
|
||||
HTTPMethod: "POST",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &UploadCertificateInput{}
|
||||
}
|
||||
|
||||
output = &UploadCertificateOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CERTIFICATESERVICE) UploadCertificateWithContext(ctx byteplus.Context, input *UploadCertificateInput, opts ...request.Option) (*UploadCertificateOutput, error) {
|
||||
req, out := c.UploadCertificateRequest(input)
|
||||
req.SetContext(ctx)
|
||||
req.ApplyOptions(opts...)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
type UploadCertificateInput struct {
|
||||
_ struct{} `type:"structure" json:",omitempty"`
|
||||
|
||||
CertificateInfo *CertificateInfoForUploadCertificateInput `type:"structure" json:",omitempty"`
|
||||
|
||||
NoVerifyAndFixChain *bool `type:"boolean" json:",omitempty"`
|
||||
|
||||
ProjectName *string `type:"string" json:",omitempty"`
|
||||
|
||||
Repeatable *bool `type:"boolean" json:",omitempty"`
|
||||
|
||||
Tag *string `type:"string" json:",omitempty"`
|
||||
|
||||
Tags []*TagForUploadCertificateInput `type:"list" json:",omitempty"`
|
||||
}
|
||||
|
||||
func (s UploadCertificateInput) String() string {
|
||||
return byteplusutil.Prettify(s)
|
||||
}
|
||||
|
||||
func (s UploadCertificateInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
type UploadCertificateOutput struct {
|
||||
_ struct{} `type:"structure" json:",omitempty"`
|
||||
|
||||
Metadata *response.ResponseMetadata
|
||||
|
||||
InstanceId *string `type:"string" json:",omitempty"`
|
||||
|
||||
RepeatId *string `type:"string" json:",omitempty"`
|
||||
}
|
||||
|
||||
func (s UploadCertificateOutput) String() string {
|
||||
return byteplusutil.Prettify(s)
|
||||
}
|
||||
|
||||
func (s UploadCertificateOutput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
type CertificateInfoForUploadCertificateInput struct {
|
||||
_ struct{} `type:"structure" json:",omitempty"`
|
||||
|
||||
CertificateChain *string `type:"string" json:",omitempty"`
|
||||
|
||||
PrivateKey *string `type:"string" json:",omitempty"`
|
||||
}
|
||||
|
||||
func (s CertificateInfoForUploadCertificateInput) String() string {
|
||||
return byteplusutil.Prettify(s)
|
||||
}
|
||||
|
||||
func (s CertificateInfoForUploadCertificateInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
|
||||
type TagForUploadCertificateInput struct {
|
||||
_ struct{} `type:"structure" json:",omitempty"`
|
||||
|
||||
Key *string `type:"string" json:",omitempty"`
|
||||
|
||||
Value *string `type:"string" json:",omitempty"`
|
||||
}
|
||||
|
||||
func (s TagForUploadCertificateInput) String() string {
|
||||
return byteplusutil.Prettify(s)
|
||||
}
|
||||
|
||||
func (s TagForUploadCertificateInput) GoString() string {
|
||||
return s.String()
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package certificateservice
|
||||
|
||||
import (
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/byteplusquery"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/client"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/client/metadata"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/corehandlers"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/request"
|
||||
"github.com/byteplus-sdk/byteplus-go-sdk-v2/byteplus/signer/byteplussign"
|
||||
)
|
||||
|
||||
type CERTIFICATESERVICE struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
const (
|
||||
ServiceName = "certificate_service"
|
||||
EndpointsID = ServiceName
|
||||
ServiceID = "certificate_service"
|
||||
)
|
||||
|
||||
func New(p client.ConfigProvider, cfgs ...*byteplus.Config) *CERTIFICATESERVICE {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
func newClient(cfg byteplus.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *CERTIFICATESERVICE {
|
||||
svc := &CERTIFICATESERVICE{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
ServiceID: ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2021-06-01",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler)
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHandler)
|
||||
svc.Handlers.Sign.PushBackNamed(byteplussign.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(byteplusquery.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(byteplusquery.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(byteplusquery.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(byteplusquery.UnmarshalErrorHandler)
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
func (c *CERTIFICATESERVICE) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
return req
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import BizDeployNodeConfigFieldsProviderBaotaWAF from "./BizDeployNodeConfigFiel
|
||||
import BizDeployNodeConfigFieldsProviderBaotaWAFConsole from "./BizDeployNodeConfigFieldsProviderBaotaWAFConsole";
|
||||
import BizDeployNodeConfigFieldsProviderBunnyCDN from "./BizDeployNodeConfigFieldsProviderBunnyCDN";
|
||||
import BizDeployNodeConfigFieldsProviderBytePlusCDN from "./BizDeployNodeConfigFieldsProviderBytePlusCDN";
|
||||
import BizDeployNodeConfigFieldsProviderBytePlusCertCenter from "./BizDeployNodeConfigFieldsProviderBytePlusCertCenter";
|
||||
import BizDeployNodeConfigFieldsProviderCdnfly from "./BizDeployNodeConfigFieldsProviderCdnfly";
|
||||
import BizDeployNodeConfigFieldsProviderCPanel from "./BizDeployNodeConfigFieldsProviderCPanel";
|
||||
import BizDeployNodeConfigFieldsProviderCTCCCloudAO from "./BizDeployNodeConfigFieldsProviderCTCCCloudAO";
|
||||
@@ -166,6 +167,7 @@ const providerComponentMap: Partial<Record<DeploymentProviderType, React.Compone
|
||||
[DEPLOYMENT_PROVIDERS.BAOTAWAF_CONSOLE]: BizDeployNodeConfigFieldsProviderBaotaWAFConsole,
|
||||
[DEPLOYMENT_PROVIDERS.BUNNY_CDN]: BizDeployNodeConfigFieldsProviderBunnyCDN,
|
||||
[DEPLOYMENT_PROVIDERS.BYTEPLUS_CDN]: BizDeployNodeConfigFieldsProviderBytePlusCDN,
|
||||
[DEPLOYMENT_PROVIDERS.BYTEPLUS_CERTCENTER]: BizDeployNodeConfigFieldsProviderBytePlusCertCenter,
|
||||
[DEPLOYMENT_PROVIDERS.CDNFLY]: BizDeployNodeConfigFieldsProviderCdnfly,
|
||||
[DEPLOYMENT_PROVIDERS.CPANEL]: BizDeployNodeConfigFieldsProviderCPanel,
|
||||
[DEPLOYMENT_PROVIDERS.CTCCCLOUD_AO]: BizDeployNodeConfigFieldsProviderCTCCCloudAO,
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
const BizDeployNodeConfigFieldsProviderBytePlusCertCenter = () => {
|
||||
const { i18n, t } = useTranslation();
|
||||
|
||||
const { parentNamePath } = useFormNestedFieldsContext();
|
||||
const formSchema = z.object({
|
||||
[parentNamePath]: getSchema({ i18n }),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name={[parentNamePath, "region"]}
|
||||
initialValue={initialValues.region}
|
||||
label={t("workflow_node.deploy.form.byteplus_certcenter_region.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("workflow_node.deploy.form.byteplus_certcenter_region.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
region: "ap-singapore-1",
|
||||
};
|
||||
};
|
||||
|
||||
const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> }) => {
|
||||
const { t: _ } = i18n;
|
||||
|
||||
return z.object({
|
||||
region: z.string().nonempty(),
|
||||
});
|
||||
};
|
||||
|
||||
const _default = Object.assign(BizDeployNodeConfigFieldsProviderBytePlusCertCenter, {
|
||||
getInitialValues,
|
||||
getSchema,
|
||||
});
|
||||
|
||||
export default _default;
|
||||
+1
-1
@@ -31,7 +31,7 @@ const BizDeployNodeConfigFieldsProviderVolcEngineCertCenter = () => {
|
||||
|
||||
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
|
||||
return {
|
||||
region: "",
|
||||
region: "cn-beijing",
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -622,6 +622,7 @@ export const DEPLOYMENT_PROVIDERS = Object.freeze({
|
||||
BAOTAWAF_CONSOLE: `${ACCESS_PROVIDERS.BAOTAWAF}-console`,
|
||||
BUNNY_CDN: `${ACCESS_PROVIDERS.BUNNY}-cdn`,
|
||||
BYTEPLUS_CDN: `${ACCESS_PROVIDERS.BYTEPLUS}-cdn`,
|
||||
BYTEPLUS_CERTCENTER: `${ACCESS_PROVIDERS.BYTEPLUS}-certcenter`,
|
||||
CACHEFLY: `${ACCESS_PROVIDERS.CACHEFLY}`,
|
||||
CDNFLY: `${ACCESS_PROVIDERS.CDNFLY}`,
|
||||
CPANEL: `${ACCESS_PROVIDERS.CPANEL}`,
|
||||
@@ -825,6 +826,7 @@ export const deploymentProvidersMap: Map<DeploymentProvider["type"] | string, De
|
||||
[DEPLOYMENT_PROVIDERS.KSYUN_CDN, "provider.ksyun_cdn", DEPLOYMENT_CATEGORIES.CDN],
|
||||
[DEPLOYMENT_PROVIDERS.KSYUN_SLB, "provider.ksyun_slb", DEPLOYMENT_CATEGORIES.LOADBALANCE],
|
||||
[DEPLOYMENT_PROVIDERS.BYTEPLUS_CDN, "provider.byteplus_cdn", DEPLOYMENT_CATEGORIES.CDN],
|
||||
[DEPLOYMENT_PROVIDERS.BYTEPLUS_CERTCENTER, "provider.byteplus_certcenter_upload", DEPLOYMENT_CATEGORIES.SSL],
|
||||
[DEPLOYMENT_PROVIDERS.UCLOUD_US3, "provider.ucloud_us3", DEPLOYMENT_CATEGORIES.STORAGE],
|
||||
[DEPLOYMENT_PROVIDERS.UCLOUD_UCDN, "provider.ucloud_ucdn", DEPLOYMENT_CATEGORIES.CDN],
|
||||
[DEPLOYMENT_PROVIDERS.UCLOUD_UCLB, "provider.ucloud_uclb", DEPLOYMENT_CATEGORIES.LOADBALANCE],
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
"bunny_cdn": "Bunny - CDN (Content Delivery Network)",
|
||||
"byteplus": "BytePlus",
|
||||
"byteplus_cdn": "BytePlus - CDN (Content Delivery Network)",
|
||||
"byteplus_certcenter_upload": "BytePlus - Upload to Certificate Center",
|
||||
"byteplus_dns": "BytePlus - DNS",
|
||||
"cachefly": "CacheFly",
|
||||
"cdnfly": "Cdnfly",
|
||||
|
||||
@@ -1213,6 +1213,10 @@
|
||||
"label": "BytePlus CDN domain",
|
||||
"placeholder": "Please enter BytePlus CDN domain name"
|
||||
},
|
||||
"byteplus_certcenter_region": {
|
||||
"label": "BytePlus region",
|
||||
"placeholder": "Please enter BytePlus Certificate Center region (e.g. ap-singapore-1)"
|
||||
},
|
||||
"cdnfly_deploy_target": {
|
||||
"option": {
|
||||
"website": {
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
"bunny_cdn": "Bunny - 内容分发网络 CDN",
|
||||
"byteplus": "BytePlus",
|
||||
"byteplus_cdn": "BytePlus - 内容分发网络 CDN",
|
||||
"byteplus_certcenter_upload": "BytePlus - 上传到证书中心",
|
||||
"byteplus_dns": "BytePlus - DNS",
|
||||
"cachefly": "CacheFly",
|
||||
"cdnfly": "Cdnfly",
|
||||
|
||||
@@ -1212,6 +1212,10 @@
|
||||
"label": "BytePlus CDN 域名",
|
||||
"placeholder": "请输入 BytePlus CDN 域名"
|
||||
},
|
||||
"byteplus_certcenter_region": {
|
||||
"label": "BytePlus 证书中心服务地域",
|
||||
"placeholder": "请输入 BytePlus 证书中心服务地域(例如:ap-singapore-1)"
|
||||
},
|
||||
"cdnfly_deploy_target": {
|
||||
"option": {
|
||||
"website": {
|
||||
|
||||
Reference in New Issue
Block a user