mirror of
https://github.com/certimate-go/certimate.git
synced 2026-10-30 18:29:52 +08:00
refactor: move all partial copy of package dependencies to /pkg/sdk3rd-trimmed
This commit is contained in:
@@ -55,7 +55,7 @@ require (
|
||||
github.com/pavlo-v-chernykh/keystore-go/v4 v4.5.0
|
||||
github.com/pkg/sftp v1.13.10
|
||||
github.com/pocketbase/dbx v1.12.0
|
||||
github.com/pocketbase/pocketbase v0.38.0
|
||||
github.com/pocketbase/pocketbase v0.38.1
|
||||
github.com/povsister/scp v0.0.0-20250701154629-777cf82de5df
|
||||
github.com/pquerna/otp v1.5.0
|
||||
github.com/qiniu/go-sdk/v7 v7.26.12
|
||||
|
||||
@@ -806,6 +806,8 @@ github.com/pocketbase/dbx v1.12.0 h1:/oLErM+A0b4xI0PWTGPqSDVjzix48PqI/bng2l0PzoA
|
||||
github.com/pocketbase/dbx v1.12.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
|
||||
github.com/pocketbase/pocketbase v0.38.0 h1:EwZiOpu2RwJ7O0d0+W+rUAGeXvBhH6zpZOX37wFB830=
|
||||
github.com/pocketbase/pocketbase v0.38.0/go.mod h1:gxdfarbZ4gT/ivRNiIa7uJ1a64eY8yncW+NyvA31aLk=
|
||||
github.com/pocketbase/pocketbase v0.38.1 h1:wNFm9Nw18D/6hZP5Q+Biz1LSz3bkcFmfb318GoJ/UXo=
|
||||
github.com/pocketbase/pocketbase v0.38.1/go.mod h1:j2+DlxYqUanERfruYvkBDMKOASfRJUrQKMJdscmookA=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/povsister/scp v0.0.0-20250701154629-777cf82de5df h1:zEgSHrxo8f6hGG1xCaqunfBq8hlfDmFd1JM0QXiQi7o=
|
||||
|
||||
@@ -8,14 +8,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
alicas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas/internal"
|
||||
alicas "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -33,7 +32,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CasClient
|
||||
sdkClient *alicas.Client
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -130,7 +129,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
c.logger.Info("ssl certificate already exists")
|
||||
return &certmgr.UploadResult{
|
||||
CertId: fmt.Sprintf("%d", tea.Int64Value(certItem.CertificateId)),
|
||||
CertName: *certItem.Name,
|
||||
CertName: tea.StringValue(certItem.Name),
|
||||
ExtendedData: map[string]any{
|
||||
"InstanceId": tea.StringValue(getUserCertificateDetailResp.Body.InstanceId),
|
||||
"CertIdentifier": tea.StringValue(getUserCertificateDetailResp.Body.CertIdentifier),
|
||||
@@ -188,7 +187,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.CasClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alicas.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/cas
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -204,7 +203,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Cas
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
}
|
||||
|
||||
client, err := internal.NewCasClient(config)
|
||||
client, err := alicas.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
alicas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/cas-20200407/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CasClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewCasClient(config *openapiutil.Config) (*CasClient, error) {
|
||||
client := new(CasClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *CasClient) Init(config *openapiutil.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *CasClient) GetUserCertificateDetailWithContext(ctx context.Context, request *alicas.GetUserCertificateDetailRequest, runtime *dara.RuntimeOptions) (_result *alicas.GetUserCertificateDetailResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CertFilter) {
|
||||
query["CertFilter"] = request.CertFilter
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.CertId) {
|
||||
query["CertId"] = request.CertId
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("GetUserCertificateDetail"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.GetUserCertificateDetailResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *CasClient) ListUserCertificateOrderWithContext(ctx context.Context, request *alicas.ListUserCertificateOrderRequest, runtime *dara.RuntimeOptions) (_result *alicas.ListUserCertificateOrderResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CurrentPage) {
|
||||
query["CurrentPage"] = request.CurrentPage
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Keyword) {
|
||||
query["Keyword"] = request.Keyword
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.OrderType) {
|
||||
query["OrderType"] = request.OrderType
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceGroupId) {
|
||||
query["ResourceGroupId"] = request.ResourceGroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ShowSize) {
|
||||
query["ShowSize"] = request.ShowSize
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Status) {
|
||||
query["Status"] = request.Status
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("ListUserCertificateOrder"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.ListUserCertificateOrderResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *CasClient) UploadUserCertificateWithContext(ctx context.Context, request *alicas.UploadUserCertificateRequest, runtime *dara.RuntimeOptions) (_result *alicas.UploadUserCertificateResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.Cert) {
|
||||
query["Cert"] = request.Cert
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.EncryptCert) {
|
||||
query["EncryptCert"] = request.EncryptCert
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.EncryptPrivateKey) {
|
||||
query["EncryptPrivateKey"] = request.EncryptPrivateKey
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Key) {
|
||||
query["Key"] = request.Key
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Name) {
|
||||
query["Name"] = request.Name
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceGroupId) {
|
||||
query["ResourceGroupId"] = request.ResourceGroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SignCert) {
|
||||
query["SignCert"] = request.SignCert
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SignPrivateKey) {
|
||||
query["SignPrivateKey"] = request.SignPrivateKey
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Tags) {
|
||||
query["Tags"] = request.Tags
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("UploadUserCertificate"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.UploadUserCertificateResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -13,13 +13,12 @@ import (
|
||||
"time"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alislb "github.com/alibabacloud-go/slb-20140515/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-slb/internal"
|
||||
alislb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/slb-20140515/v4/client"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -37,7 +36,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.SlbClient
|
||||
sdkClient *alislb.Client
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -110,8 +109,8 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
// 如果以上信息都一致,则视为已存在相同证书,直接返回
|
||||
c.logger.Info("ssl certificate already exists")
|
||||
return &certmgr.UploadResult{
|
||||
CertId: *certItem.ServerCertificateId,
|
||||
CertName: *certItem.ServerCertificateName,
|
||||
CertId: tea.StringValue(certItem.ServerCertificateId),
|
||||
CertName: tea.StringValue(certItem.ServerCertificateName),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
@@ -150,7 +149,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.SlbClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alislb.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/Slb
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -170,7 +169,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Slb
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
}
|
||||
|
||||
client, err := internal.NewSlbClient(config)
|
||||
client, err := alislb.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
alislb "github.com/alibabacloud-go/slb-20140515/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/slb-20140515/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type SlbClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewSlbClient(config *openapi.Config) (*SlbClient, error) {
|
||||
client := new(SlbClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *SlbClient) Init(config *openapi.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *SlbClient) DescribeServerCertificatesWithContext(ctx context.Context, request *alislb.DescribeServerCertificatesRequest, runtime *dara.RuntimeOptions) (_result *alislb.DescribeServerCertificatesResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
query := map[string]interface{}{}
|
||||
if !dara.IsNil(request.OwnerAccount) {
|
||||
query["OwnerAccount"] = request.OwnerAccount
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.OwnerId) {
|
||||
query["OwnerId"] = request.OwnerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.RegionId) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceGroupId) {
|
||||
query["ResourceGroupId"] = request.ResourceGroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceOwnerAccount) {
|
||||
query["ResourceOwnerAccount"] = request.ResourceOwnerAccount
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceOwnerId) {
|
||||
query["ResourceOwnerId"] = request.ResourceOwnerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ServerCertificateId) {
|
||||
query["ServerCertificateId"] = request.ServerCertificateId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Tag) {
|
||||
query["Tag"] = request.Tag
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("DescribeServerCertificates"),
|
||||
Version: dara.String("2014-05-15"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alislb.DescribeServerCertificatesResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *SlbClient) UploadServerCertificateWithContext(ctx context.Context, request *alislb.UploadServerCertificateRequest, runtime *dara.RuntimeOptions) (_result *alislb.UploadServerCertificateResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
query := map[string]interface{}{}
|
||||
if !dara.IsNil(request.AliCloudCertificateId) {
|
||||
query["AliCloudCertificateId"] = request.AliCloudCertificateId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.AliCloudCertificateName) {
|
||||
query["AliCloudCertificateName"] = request.AliCloudCertificateName
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.AliCloudCertificateRegionId) {
|
||||
query["AliCloudCertificateRegionId"] = request.AliCloudCertificateRegionId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.OwnerAccount) {
|
||||
query["OwnerAccount"] = request.OwnerAccount
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.OwnerId) {
|
||||
query["OwnerId"] = request.OwnerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.PrivateKey) {
|
||||
query["PrivateKey"] = request.PrivateKey
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.RegionId) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceGroupId) {
|
||||
query["ResourceGroupId"] = request.ResourceGroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceOwnerAccount) {
|
||||
query["ResourceOwnerAccount"] = request.ResourceOwnerAccount
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceOwnerId) {
|
||||
query["ResourceOwnerId"] = request.ResourceOwnerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ServerCertificate) {
|
||||
query["ServerCertificate"] = request.ServerCertificate
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ServerCertificateName) {
|
||||
query["ServerCertificateName"] = request.ServerCertificateName
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Tag) {
|
||||
query["Tag"] = request.Tag
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("UploadServerCertificate"),
|
||||
Version: dara.String("2014-05-15"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alislb.UploadServerCertificateResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package awsacm_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fRegion string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "AWSACM_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fSecretAccessKey, argsPrefix+"SECRETACCESSKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./aws_acm_test.go -args \
|
||||
--AWSACM_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--AWSACM_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--AWSACM_ACCESSKEYID="your-access-key-id" \
|
||||
--AWSACM_SECRETACCESSKEY="your-access-key-secret" \
|
||||
--AWSACM_REGION="us-east-1"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("SECRETACCESSKEY: %v", fSecretAccessKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Region: fRegion,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package awsiam_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fRegion string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "AWSIAM_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fSecretAccessKey, argsPrefix+"SECRETACCESSKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./aws_iam_test.go -args \
|
||||
--AWSIAM_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--AWSIAM_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--AWSIAM_ACCESSKEYID="your-access-key-id" \
|
||||
--AWSIAM_SECRETACCESSKEY="your-access-key-secret" \
|
||||
--AWSIAM_REGION="us-east-1"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("SECRETACCESSKEY: %v", fSecretAccessKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Region: fRegion,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package dogecloud_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dogecloud"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "DOGECLOUD_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKey, argsPrefix+"ACCESSKEY", "", "")
|
||||
flag.StringVar(&fSecretKey, argsPrefix+"SECRETKEY", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./dogecloud_test.go -args \
|
||||
--DOGECLOUD_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--DOGECLOUD_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--DOGECLOUD_ACCESSKEY="your-access-key" \
|
||||
--DOGECLOUD_SECRETKEY="your-secret-key"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEY: %v", fAccessKey),
|
||||
fmt.Sprintf("SECRETKEY: %v", fSecretKey),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package gcorecdn_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/gcore-cdn"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fApiToken string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "GCORECDN_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fApiToken, argsPrefix+"APITOKEN", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./gcore_cdn_test.go -args \
|
||||
--GCORECDN_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--GCORECDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--GCORECDN_APITOKEN="your-api-token"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("APITOKEN: %v", fApiToken),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
ApiToken: fApiToken,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -9,16 +9,15 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hcelb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
hcelbmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
hcelbregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwelbmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
hwelbregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-elb/internal"
|
||||
hwelb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ElbClient
|
||||
sdkClient *hwelb.ElbClient
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -77,7 +76,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
listCertificatesReq := &hcelbmodel.ListCertificatesRequest{
|
||||
listCertificatesReq := &hwelbmodel.ListCertificatesRequest{
|
||||
Marker: listCertificatesMarker,
|
||||
Limit: lo.ToPtr(int32(2000)),
|
||||
Type: lo.ToPtr([]string{"server"}),
|
||||
@@ -122,9 +121,9 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 创建新证书
|
||||
// REF: https://support.huaweicloud.com/api-elb/CreateCertificate.html
|
||||
createCertificateReq := &hcelbmodel.CreateCertificateRequest{
|
||||
Body: &hcelbmodel.CreateCertificateRequestBody{
|
||||
Certificate: &hcelbmodel.CreateCertificateOption{
|
||||
createCertificateReq := &hwelbmodel.CreateCertificateRequest{
|
||||
Body: &hwelbmodel.CreateCertificateRequestBody{
|
||||
Certificate: &hwelbmodel.CreateCertificateOption{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
ProjectId: lo.ToPtr(projectId),
|
||||
Name: lo.ToPtr(certName),
|
||||
@@ -148,10 +147,10 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, privkeyPEM string) (*certmgr.OperateResult, error) {
|
||||
// 更新证书
|
||||
// REF: https://support.huaweicloud.com/api-elb/UpdateCertificate.html
|
||||
updateCertificateReq := &hcelbmodel.UpdateCertificateRequest{
|
||||
updateCertificateReq := &hwelbmodel.UpdateCertificateRequest{
|
||||
CertificateId: certIdOrName,
|
||||
Body: &hcelbmodel.UpdateCertificateRequestBody{
|
||||
Certificate: &hcelbmodel.UpdateCertificateOption{
|
||||
Body: &hwelbmodel.UpdateCertificateRequestBody{
|
||||
Certificate: &hwelbmodel.UpdateCertificateOption{
|
||||
Certificate: lo.ToPtr(certPEM),
|
||||
PrivateKey: lo.ToPtr(privkeyPEM),
|
||||
},
|
||||
@@ -166,7 +165,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return &certmgr.OperateResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ElbClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwelb.ElbClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-4" // ELB 服务默认区域:华北北京四
|
||||
}
|
||||
@@ -179,12 +178,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Elb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcelbregion.SafeValueOf(region)
|
||||
hcRegion, err := hwelbregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcelb.ElbClientBuilder().
|
||||
hcClient, err := hwelb.ElbClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -192,7 +191,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Elb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewElbClient(hcClient)
|
||||
client := hwelb.NewElbClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -209,12 +208,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -222,9 +221,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciammodel.KeystoneListProjectsRequest{
|
||||
request := &hwiammodel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package huaweicloudelb_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-elb"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fRegion string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "HUAWEICLOUDELB_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fSecretAccessKey, argsPrefix+"SECRETACCESSKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./huaweicloud_elb_test.go -args \
|
||||
--HUAWEICLOUDELB_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--HUAWEICLOUDELB_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--HUAWEICLOUDELB_ACCESSKEYID="your-access-key-id" \
|
||||
--HUAWEICLOUDELB_SECRETACCESSKEY="your-access-key-secret" \
|
||||
--HUAWEICLOUDELB_REGION="cn-north-4"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("SECRETACCESSKEY: %v", fSecretAccessKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Region: fRegion,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwelb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/elb/v3/elb_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ElbClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewElbClient(hcClient *httpclient.HcHttpClient) *ElbClient {
|
||||
return &ElbClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *ElbClient) CreateCertificate(request *model.CreateCertificateRequest) (*model.CreateCertificateResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForCreateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) UpdateCertificate(request *model.UpdateCertificateRequest) (*model.UpdateCertificateResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForUpdateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
hcscm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3"
|
||||
hcscmmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model"
|
||||
hcscmregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/region"
|
||||
hwscmmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model"
|
||||
hwscmregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm/internal"
|
||||
hwscm "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -33,7 +32,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ScmClient
|
||||
sdkClient *hwscm.ScmClient
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -82,7 +81,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
listCertificatesReq := &hcscmmodel.ListCertificatesRequest{
|
||||
listCertificatesReq := &hwscmmodel.ListCertificatesRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
Limit: lo.ToPtr(int32(listCertificatesLimit)),
|
||||
Offset: lo.ToPtr(int32(listCertificatesOffset)),
|
||||
@@ -111,7 +110,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
}
|
||||
|
||||
// 对比证书内容
|
||||
exportCertificateReq := &hcscmmodel.ExportCertificateRequest{
|
||||
exportCertificateReq := &hwscmmodel.ExportCertificateRequest{
|
||||
CertificateId: certItem.Id,
|
||||
}
|
||||
exportCertificateResp, err := c.sdkClient.ExportCertificate(exportCertificateReq)
|
||||
@@ -147,8 +146,8 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 上传新证书
|
||||
// REF: https://support.huaweicloud.com/api-ccm/ImportCertificate.html
|
||||
importCertificateReq := &hcscmmodel.ImportCertificateRequest{
|
||||
Body: &hcscmmodel.ImportCertificateRequestBody{
|
||||
importCertificateReq := &hwscmmodel.ImportCertificateRequest{
|
||||
Body: &hwscmmodel.ImportCertificateRequestBody{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
Name: certName,
|
||||
Certificate: certPEM,
|
||||
@@ -171,7 +170,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ScmClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwscm.ScmClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-4" // SCM 服务默认区域:华北北京四
|
||||
}
|
||||
@@ -184,12 +183,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Scm
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcscmregion.SafeValueOf(region)
|
||||
hcRegion, err := hwscmregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcscm.ScmClientBuilder().
|
||||
hcClient, err := hwscm.ScmClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -197,6 +196,6 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Scm
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewScmClient(hcClient)
|
||||
client := hwscm.NewScmClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package huaweicloudscm_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fRegion string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "HUAWEICLOUDSCM_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fSecretAccessKey, argsPrefix+"SECRETACCESSKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./huaweicloud_scm_test.go -args \
|
||||
--HUAWEICLOUDSCM_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--HUAWEICLOUDSCM_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--HUAWEICLOUDSCM_ACCESSKEYID="your-access-key-id" \
|
||||
--HUAWEICLOUDSCM_SECRETACCESSKEY="your-access-key-secret" \
|
||||
--HUAWEICLOUDSCM_REGION="cn-north-4"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("SECRETACCESSKEY: %v", fSecretAccessKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Region: fRegion,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -9,16 +9,15 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hcwaf "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
hcwafmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
hcwafregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwwafmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
hwwafregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-waf/internal"
|
||||
hwwaf "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.WafClient
|
||||
sdkClient *hwwaf.WafClient
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -79,7 +78,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
listCertificatesReq := &hcwafmodel.ListCertificatesRequest{
|
||||
listCertificatesReq := &hwwafmodel.ListCertificatesRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
Page: lo.ToPtr(int32(listCertificatesPage)),
|
||||
Pagesize: lo.ToPtr(int32(listCertificatesPageSize)),
|
||||
@@ -95,7 +94,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
}
|
||||
|
||||
for _, certItem := range *listCertificatesResp.Items {
|
||||
showCertificateReq := &hcwafmodel.ShowCertificateRequest{
|
||||
showCertificateReq := &hwwafmodel.ShowCertificateRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
CertificateId: certItem.Id,
|
||||
}
|
||||
@@ -127,9 +126,9 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 创建证书
|
||||
// REF: https://support.huaweicloud.com/api-waf/CreateCertificate.html
|
||||
createCertificateReq := &hcwafmodel.CreateCertificateRequest{
|
||||
createCertificateReq := &hwwafmodel.CreateCertificateRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(c.config.EnterpriseProjectId),
|
||||
Body: &hcwafmodel.CreateCertificateRequestBody{
|
||||
Body: &hwwafmodel.CreateCertificateRequestBody{
|
||||
Name: certName,
|
||||
Content: certPEM,
|
||||
Key: privkeyPEM,
|
||||
@@ -151,7 +150,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwwaf.WafClient, error) {
|
||||
projectId, err := getSDKProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -166,12 +165,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Waf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcwafregion.SafeValueOf(region)
|
||||
hcRegion, err := hwwafregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcwaf.WafClientBuilder().
|
||||
hcClient, err := hwwaf.WafClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -179,7 +178,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Waf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewWafClient(hcClient)
|
||||
client := hwwaf.NewWafClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -192,12 +191,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -205,9 +204,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciammodel.KeystoneListProjectsRequest{
|
||||
request := &hwiammodel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package huaweicloudwaf_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-waf"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fRegion string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "HUAWEICLOUDWAF_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fSecretAccessKey, argsPrefix+"SECRETACCESSKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./huaweicloud_waf_test.go -args \
|
||||
--HUAWEICLOUDWAF_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--HUAWEICLOUDWAF_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--HUAWEICLOUDWAF_ACCESSKEYID="your-access-key-id" \
|
||||
--HUAWEICLOUDWAF_SECRETACCESSKEY="your-access-key-secret" \
|
||||
--HUAWEICLOUDWAF_REGION="cn-north-4"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("SECRETACCESSKEY: %v", fSecretAccessKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Region: fRegion,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwwaf "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/waf/v1/waf_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type WafClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewWafClient(hcClient *httpclient.HcHttpClient) *WafClient {
|
||||
return &WafClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *WafClient) CreateCertificate(request *model.CreateCertificateRequest) (*model.CreateCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForCreateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ShowCertificate(request *model.ShowCertificateRequest) (*model.ShowCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForShowCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"time"
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdsslapi "github.com/jdcloud-api/jdcloud-sdk-go/services/ssl/apis"
|
||||
jdsslclient "github.com/jdcloud-api/jdcloud-sdk-go/services/ssl/client"
|
||||
jdsslapis "github.com/jdcloud-api/jdcloud-sdk-go/services/ssl/apis"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
jdssl "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/ssl/client"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *jdsslclient.SslClient
|
||||
sdkClient *jdssl.SslClient
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -82,7 +82,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
describeCertsReq := jdsslapi.NewDescribeCertsRequestWithoutParam()
|
||||
describeCertsReq := jdsslapis.NewDescribeCertsRequestWithoutParam()
|
||||
describeCertsReq.SetDomainName(certX509.Subject.CommonName)
|
||||
describeCertsReq.SetPageNumber(describeCertsPageNumber)
|
||||
describeCertsReq.SetPageSize(describeCertsPageSize)
|
||||
@@ -137,7 +137,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 上传证书
|
||||
// REF: https://docs.jdcloud.com/cn/ssl-certificate/api/uploadcert
|
||||
uploadCertReq := jdsslapi.NewUploadCertRequestWithoutParam()
|
||||
uploadCertReq := jdsslapis.NewUploadCertRequestWithoutParam()
|
||||
uploadCertReq.SetCertName(certName)
|
||||
uploadCertReq.SetCertFile(certPEM)
|
||||
uploadCertReq.SetKeyFile(privkeyPEM)
|
||||
@@ -157,9 +157,9 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdsslclient.SslClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdssl.SslClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := jdsslclient.NewSslClient(clientCredentials)
|
||||
client := jdssl.NewSslClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
tcssl "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/TencentCloud/tencentcloud-sdk-go/blob/master/tencentcloud/ssl/v20191205/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type SslClient struct {
|
||||
common.Client
|
||||
}
|
||||
|
||||
func NewSslClient(credential common.CredentialIface, region string, clientProfile *profile.ClientProfile) (client *SslClient, err error) {
|
||||
client = &SslClient{}
|
||||
client.Init(region).
|
||||
WithCredential(credential).
|
||||
WithProfile(clientProfile)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *SslClient) UploadCertificate(request *tcssl.UploadCertificateRequest) (response *tcssl.UploadCertificateResponse, err error) {
|
||||
return c.UploadCertificateWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *SslClient) UploadCertificateWithContext(ctx context.Context, request *tcssl.UploadCertificateRequest) (response *tcssl.UploadCertificateResponse, err error) {
|
||||
if request == nil {
|
||||
request = tcssl.NewUploadCertificateRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "ssl", tcssl.APIVersion, "UploadCertificate")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("UploadCertificate require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tcssl.NewUploadCertificateResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
@@ -8,10 +8,9 @@ import (
|
||||
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
tcssl "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl/internal"
|
||||
tcssl "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl/v20191205"
|
||||
)
|
||||
|
||||
type CertmgrConfig struct {
|
||||
@@ -26,7 +25,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.SslClient
|
||||
sdkClient *tcssl.Client
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -63,7 +62,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
uploadCertificateReq.CertificatePublicKey = common.StringPtr(certPEM)
|
||||
uploadCertificateReq.CertificatePrivateKey = common.StringPtr(privkeyPEM)
|
||||
uploadCertificateReq.Repeatable = common.BoolPtr(false)
|
||||
uploadCertificateResp, err := c.sdkClient.UploadCertificate(uploadCertificateReq)
|
||||
uploadCertificateResp, err := c.sdkClient.UploadCertificateWithContext(ctx, uploadCertificateReq)
|
||||
c.logger.Debug("sdk request 'ssl.UploadCertificate'", slog.Any("request", uploadCertificateReq), slog.Any("response", uploadCertificateResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'ssl.UploadCertificate': %w", err)
|
||||
@@ -78,7 +77,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(secretId, secretKey, endpoint string) (*internal.SslClient, error) {
|
||||
func createSDKClient(secretId, secretKey, endpoint string) (*tcssl.Client, error) {
|
||||
credential := common.NewCredential(secretId, secretKey)
|
||||
|
||||
cpf := profile.NewClientProfile()
|
||||
@@ -86,7 +85,7 @@ func createSDKClient(secretId, secretKey, endpoint string) (*internal.SslClient,
|
||||
cpf.HttpProfile.Endpoint = endpoint
|
||||
}
|
||||
|
||||
client, err := internal.NewSslClient(credential, "", cpf)
|
||||
client, err := tcssl.NewClient(credential, "", cpf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"github.com/volcengine/volcengine-go-sdk/service/cdn"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/client"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/client/metadata"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/corehandlers"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/signer/volc"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/volcenginequery"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/volcengine/volcengine-go-sdk/blob/master/service/cdn/service_cdn.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CdnClient struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
func NewCdnClient(p client.ConfigProvider, cfgs ...*volcengine.Config) *CdnClient {
|
||||
c := p.ClientConfig(cdn.EndpointsID, cfgs...)
|
||||
return newCdnClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
func newCdnClient(cfg volcengine.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *CdnClient {
|
||||
svc := &CdnClient{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: cdn.ServiceName,
|
||||
ServiceID: cdn.ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2021-03-01",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler)
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHandler)
|
||||
svc.Handlers.Sign.PushBackNamed(volc.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(volcenginequery.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(volcenginequery.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(volcenginequery.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(volcenginequery.UnmarshalErrorHandler)
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
func (c *CdnClient) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
func (c *CdnClient) AddCertificate(input *cdn.AddCertificateInput) (*cdn.AddCertificateOutput, error) {
|
||||
req, out := c.AddCertificateRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
func (c *CdnClient) AddCertificateRequest(input *cdn.AddCertificateInput) (req *request.Request, output *cdn.AddCertificateOutput) {
|
||||
op := &request.Operation{
|
||||
Name: "AddCertificate",
|
||||
HTTPMethod: "POST",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &cdn.AddCertificateInput{}
|
||||
}
|
||||
|
||||
output = &cdn.AddCertificateOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CdnClient) ListCertInfo(input *cdn.ListCertInfoInput) (*cdn.ListCertInfoOutput, error) {
|
||||
req, out := c.ListCertInfoRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
func (c *CdnClient) ListCertInfoRequest(input *cdn.ListCertInfoInput) (req *request.Request, output *cdn.ListCertInfoOutput) {
|
||||
op := &request.Operation{
|
||||
Name: "ListCertInfo",
|
||||
HTTPMethod: "POST",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &cdn.ListCertInfoInput{}
|
||||
}
|
||||
|
||||
output = &cdn.ListCertInfoOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
return
|
||||
}
|
||||
@@ -11,12 +11,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
vecdn "github.com/volcengine/volcengine-go-sdk/service/cdn"
|
||||
ve "github.com/volcengine/volcengine-go-sdk/volcengine"
|
||||
vesession "github.com/volcengine/volcengine-go-sdk/volcengine/session"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-cdn/internal"
|
||||
vecdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/volcengine/volcengine-go-sdk/service/cdn"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -30,7 +29,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CdnClient
|
||||
sdkClient *vecdn.CDN
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -83,7 +82,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
PageNum: ve.Int32(int32(listCertInfoPageNum)),
|
||||
PageSize: ve.Int32(int32(listCertInfoPageSize)),
|
||||
}
|
||||
listCertInfoResp, err := c.sdkClient.ListCertInfo(listCertInfoReq)
|
||||
listCertInfoResp, err := c.sdkClient.ListCertInfoWithContext(ctx, listCertInfoReq)
|
||||
c.logger.Debug("sdk request 'cdn.ListCertInfo'", slog.Any("request", listCertInfoReq), slog.Any("response", listCertInfoResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'cdn.ListCertInfo': %w", err)
|
||||
@@ -128,8 +127,8 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
PrivateKey: ve.String(privkeyPEM),
|
||||
Desc: ve.String(certName),
|
||||
}
|
||||
addCertificateResp, err := c.sdkClient.AddCertificate(addCertificateReq)
|
||||
c.logger.Debug("sdk request 'cdn.AddCertificate'", slog.Any("request", addCertificateResp), slog.Any("response", addCertificateResp))
|
||||
addCertificateResp, err := c.sdkClient.AddCertificateWithContext(ctx, addCertificateReq)
|
||||
c.logger.Debug("sdk request 'cdn.AddCertificate'", slog.Any("request", addCertificateReq), slog.Any("response", addCertificateResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'cdn.AddCertificate': %w", err)
|
||||
}
|
||||
@@ -144,7 +143,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.CdnClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*vecdn.CDN, error) {
|
||||
config := ve.NewConfig().
|
||||
WithAkSk(accessKeyId, accessKeySecret).
|
||||
WithRegion("cn-north-1")
|
||||
@@ -154,6 +153,6 @@ func createSDKClient(accessKeyId, accessKeySecret string) (*internal.CdnClient,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewCdnClient(session)
|
||||
client := vecdn.New(session)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package volcenginecdn_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-cdn"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fAccessKeySecret string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "VOLCENGINECDN_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fAccessKeySecret, argsPrefix+"ACCESSKEYSECRET", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./volcengine_cdn_test.go -args \
|
||||
--VOLCENGINECDN_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--VOLCENGINECDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--VOLCENGINECDN_ACCESSKEYID="your-access-key-id" \
|
||||
--VOLCENGINECDN_ACCESSKEYSECRET="your-access-key-secret"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("ACCESSKEYSECRET: %v", fAccessKeySecret),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKeySecret: fAccessKeySecret,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"github.com/volcengine/volcengine-go-sdk/service/certificateservice"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/client"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/client/metadata"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/corehandlers"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/request"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/signer/volc"
|
||||
"github.com/volcengine/volcengine-go-sdk/volcengine/volcenginequery"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/volcengine/volcengine-go-sdk/blob/master/service/certificateservice/service_certificateservice.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CertificateserviceClient struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
func NewCertificateserviceClient(p client.ConfigProvider, cfgs ...*volcengine.Config) *CertificateserviceClient {
|
||||
c := p.ClientConfig(certificateservice.EndpointsID, cfgs...)
|
||||
return newCertificateserviceClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
func newCertificateserviceClient(cfg volcengine.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *CertificateserviceClient {
|
||||
svc := &CertificateserviceClient{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: certificateservice.ServiceName,
|
||||
ServiceID: certificateservice.ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2024-10-01",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler)
|
||||
svc.Handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHandler)
|
||||
svc.Handlers.Sign.PushBackNamed(volc.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(volcenginequery.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(volcenginequery.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(volcenginequery.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(volcenginequery.UnmarshalErrorHandler)
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
func (c *CertificateserviceClient) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
func (c *CertificateserviceClient) ImportCertificate(input *certificateservice.ImportCertificateInput) (*certificateservice.ImportCertificateOutput, error) {
|
||||
req, out := c.ImportCertificateRequest(input)
|
||||
return out, req.Send()
|
||||
}
|
||||
|
||||
func (c *CertificateserviceClient) ImportCertificateRequest(input *certificateservice.ImportCertificateInput) (req *request.Request, output *certificateservice.ImportCertificateOutput) {
|
||||
op := &request.Operation{
|
||||
Name: "ImportCertificate",
|
||||
HTTPMethod: "POST",
|
||||
HTTPPath: "/",
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
input = &certificateservice.ImportCertificateInput{}
|
||||
}
|
||||
|
||||
output = &certificateservice.ImportCertificateOutput{}
|
||||
req = c.newRequest(op, input, output)
|
||||
|
||||
req.HTTPRequest.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
return
|
||||
}
|
||||
@@ -6,12 +6,11 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
vecs "github.com/volcengine/volcengine-go-sdk/service/certificateservice"
|
||||
ve "github.com/volcengine/volcengine-go-sdk/volcengine"
|
||||
vesession "github.com/volcengine/volcengine-go-sdk/volcengine/session"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-certcenter/internal"
|
||||
vecertificateservice "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/volcengine/volcengine-go-sdk/service/certificateservice"
|
||||
)
|
||||
|
||||
type CertmgrConfig struct {
|
||||
@@ -26,7 +25,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CertificateserviceClient
|
||||
sdkClient *vecertificateservice.CERTIFICATESERVICE
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -59,14 +58,14 @@ func (c *Certmgr) SetLogger(logger *slog.Logger) {
|
||||
func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*certmgr.UploadResult, error) {
|
||||
// 上传证书
|
||||
// REF: https://www.volcengine.com/docs/6638/1365580
|
||||
importCertificateReq := &vecs.ImportCertificateInput{
|
||||
CertificateInfo: &vecs.CertificateInfoForImportCertificateInput{
|
||||
importCertificateReq := &vecertificateservice.ImportCertificateInput{
|
||||
CertificateInfo: &vecertificateservice.CertificateInfoForImportCertificateInput{
|
||||
CertificateChain: ve.String(certPEM),
|
||||
PrivateKey: ve.String(privkeyPEM),
|
||||
},
|
||||
Repeatable: ve.Bool(false),
|
||||
}
|
||||
importCertificateResp, err := c.sdkClient.ImportCertificate(importCertificateReq)
|
||||
importCertificateResp, err := c.sdkClient.ImportCertificateWithContext(ctx, importCertificateReq)
|
||||
c.logger.Debug("sdk request 'certcenter.ImportCertificate'", slog.Any("request", importCertificateReq), slog.Any("response", importCertificateResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'certcenter.ImportCertificate': %w", err)
|
||||
@@ -93,7 +92,7 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.CertificateserviceClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*vecertificateservice.CERTIFICATESERVICE, error) {
|
||||
if region == "" {
|
||||
region = "cn-beijing" // 证书中心默认区域:北京
|
||||
}
|
||||
@@ -107,6 +106,6 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Cer
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewCertificateserviceClient(session)
|
||||
client := vecertificateservice.New(session, config)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package volcenginelive_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/volcengine-live"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fAccessKeySecret string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "VOLCENGINELIVE_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fAccessKeySecret, argsPrefix+"ACCESSKEYSECRET", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./volcengine_live_test.go -args \
|
||||
--VOLCENGINELIVE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--VOLCENGINELIVE_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--VOLCENGINELIVE_ACCESSKEYID="your-access-key-id" \
|
||||
--VOLCENGINELIVE_ACCESSKEYSECRET="your-access-key-secret"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("ACCESSKEYSECRET: %v", fAccessKeySecret),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKeySecret: fAccessKeySecret,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
zcommon "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/common"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
zcdn "github.com/certimate-go/certimate/pkg/sdk3rd/zenlayer/cdn"
|
||||
zcdnsdk "github.com/certimate-go/certimate/pkg/sdk3rd/zenlayer/cdn"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *zcdn.Client
|
||||
sdkClient *zcdnsdk.Client
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -80,7 +80,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
describeCertificatesReq := zcdn.NewDescribeCertificatesRequest()
|
||||
describeCertificatesReq := zcdnsdk.NewDescribeCertificatesRequest()
|
||||
describeCertificatesReq.ResourceGroupId = c.config.ResourceGroupId
|
||||
describeCertificatesReq.PageNum = describeCertificatesPageNum
|
||||
describeCertificatesReq.PageSize = describeCertificatesPageSize
|
||||
@@ -156,7 +156,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 创建证书
|
||||
// REF: https://docs.console.zenlayer.com/api-reference/cn/networking/cdn/certificate/createcertificate
|
||||
createCertificateReq := zcdn.NewCreateCertificateRequest()
|
||||
createCertificateReq := zcdnsdk.NewCreateCertificateRequest()
|
||||
createCertificateReq.ResourceGroupId = c.config.ResourceGroupId
|
||||
createCertificateReq.CertificateLabel = certName
|
||||
createCertificateReq.CertificateContent = certPEM
|
||||
@@ -176,7 +176,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, privkeyPEM string) (*certmgr.OperateResult, error) {
|
||||
// 更新证书
|
||||
// REF: https://docs.console.zenlayer.com/api-reference/cn/networking/cdn/certificate/modifycertificate
|
||||
modifyCertificateReq := zcdn.NewModifyCertificateRequest()
|
||||
modifyCertificateReq := zcdnsdk.NewModifyCertificateRequest()
|
||||
modifyCertificateReq.CertificateId = certIdOrName
|
||||
modifyCertificateReq.CertificateContent = certPEM
|
||||
modifyCertificateReq.CertificateKey = privkeyPEM
|
||||
@@ -189,10 +189,10 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return &certmgr.OperateResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeyPassword string) (*zcdn.Client, error) {
|
||||
func createSDKClient(accessKeyId, accessKeyPassword string) (*zcdnsdk.Client, error) {
|
||||
config := zcommon.NewConfig()
|
||||
|
||||
client, err := zcdn.NewClient(config, accessKeyId, accessKeyPassword)
|
||||
client, err := zcdnsdk.NewClient(config, accessKeyId, accessKeyPassword)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package zenlayercdn_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/zenlayer-cdn"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fAccessKeyPassword string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "ZENLAYERCDN_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fAccessKeyPassword, argsPrefix+"ACCESSKEYPASSWORD", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./zenlayer_cdn_test.go -args \
|
||||
--ZENLAYERCDN_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--ZENLAYERCDN_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--ZENLAYERCDN_ACCESSKEYID="your-access-key-id" \
|
||||
--ZENLAYERCDN_ACCESSKEYPASSWORD="your-secret-access-key"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("ACCESSKEYPASSWORD: %v", fAccessKeyPassword),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKeyPassword: fAccessKeyPassword,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/common"
|
||||
zga "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/zga20230706"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/zenlayer/zenlayercloud-sdk-go/blob/main/zenlayercloud/zga20230706/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ZgaClient struct {
|
||||
*common.Client
|
||||
}
|
||||
|
||||
func NewZgaClient(config *common.Config, secretKeyId, secretKeyPassword string) (client *ZgaClient, err error) {
|
||||
client = &ZgaClient{}
|
||||
|
||||
err = client.InitWithCredential(common.NewCredential(secretKeyId, secretKeyPassword))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = client.WithConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *ZgaClient) CreateCertificate(request *zga.CreateCertificateRequest) (response *zga.CreateCertificateResponse, err error) {
|
||||
response = zga.NewCreateCertificateResponse()
|
||||
err = c.ApiCall(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ZgaClient) DescribeCertificates(request *zga.DescribeCertificatesRequest) (response *zga.DescribeCertificatesResponse, err error) {
|
||||
response = zga.NewDescribeCertificatesResponse()
|
||||
err = c.ApiCall(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ZgaClient) ModifyCertificate(request *zga.ModifyCertificateRequest) (response *zga.ModifyCertificateResponse, err error) {
|
||||
response = zga.NewModifyCertificateResponse()
|
||||
err = c.ApiCall(request, response)
|
||||
return
|
||||
}
|
||||
@@ -14,10 +14,9 @@ import (
|
||||
"time"
|
||||
|
||||
zcommon "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/common"
|
||||
zga "github.com/zenlayer/zenlayercloud-sdk-go/zenlayercloud/zga20230706"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr/providers/zenlayer-ga/internal"
|
||||
zgasdk "github.com/certimate-go/certimate/pkg/sdk3rd/zenlayer/zga"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -33,7 +32,7 @@ type CertmgrConfig struct {
|
||||
type Certmgr struct {
|
||||
config *CertmgrConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ZgaClient
|
||||
sdkClient *zgasdk.Client
|
||||
}
|
||||
|
||||
var _ certmgr.Provider = (*Certmgr)(nil)
|
||||
@@ -81,7 +80,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
default:
|
||||
}
|
||||
|
||||
describeCertificatesReq := zga.NewDescribeCertificatesRequest()
|
||||
describeCertificatesReq := zgasdk.NewDescribeCertificatesRequest()
|
||||
describeCertificatesReq.ResourceGroupId = c.config.ResourceGroupId
|
||||
describeCertificatesReq.PageNum = describeCertificatesPageNum
|
||||
describeCertificatesReq.PageSize = describeCertificatesPageSize
|
||||
@@ -157,7 +156,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
|
||||
// 创建证书
|
||||
// REF: https://docs.console.zenlayer.com/api-reference/cn/networking/zga/certificate/createcertificate
|
||||
createCertificateReq := zga.NewCreateCertificateRequest()
|
||||
createCertificateReq := zgasdk.NewCreateCertificateRequest()
|
||||
createCertificateReq.ResourceGroupId = c.config.ResourceGroupId
|
||||
createCertificateReq.CertificateLabel = certName
|
||||
createCertificateReq.CertificateContent = certPEM
|
||||
@@ -177,7 +176,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, privkeyPEM string) (*certmgr.OperateResult, error) {
|
||||
// 更新证书
|
||||
// REF: https://docs.console.zenlayer.com/api-reference/cn/networking/zga/certificate/modifycertificate
|
||||
modifyCertificateReq := zga.NewModifyCertificateRequest()
|
||||
modifyCertificateReq := zgasdk.NewModifyCertificateRequest()
|
||||
modifyCertificateReq.CertificateId = certIdOrName
|
||||
modifyCertificateReq.CertificateContent = certPEM
|
||||
modifyCertificateReq.CertificateKey = privkeyPEM
|
||||
@@ -190,10 +189,10 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return &certmgr.OperateResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeyPassword string) (*internal.ZgaClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeyPassword string) (*zgasdk.Client, error) {
|
||||
config := zcommon.NewConfig()
|
||||
|
||||
client, err := internal.NewZgaClient(config, accessKeyId, accessKeyPassword)
|
||||
client, err := zgasdk.NewClient(config, accessKeyId, accessKeyPassword)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package zenlayerga_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/certmgr/providers/zenlayer-ga"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fAccessKeyId string
|
||||
fAccessKeyPassword string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "ZENLAYERGA_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fAccessKeyId, argsPrefix+"ACCESSKEYID", "", "")
|
||||
flag.StringVar(&fAccessKeyPassword, argsPrefix+"ACCESSKEYPASSWORD", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./zenlayer_ga_test.go -args \
|
||||
--ZENLAYERGA_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--ZENLAYERGA_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--ZENLAYERGA_ACCESSKEYID="your-access-key-id" \
|
||||
--ZENLAYERGA_ACCESSKEYPASSWORD="your-secret-access-key"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ACCESSKEYID: %v", fAccessKeyId),
|
||||
fmt.Sprintf("ACCESSKEYPASSWORD: %v", fAccessKeyPassword),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewCertmgr(&provider.CertmgrConfig{
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKeyPassword: fAccessKeyPassword,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Upload(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
sres, _ := json.Marshal(res)
|
||||
t.Logf("ok: %s", string(sres))
|
||||
})
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/1panel"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/1panel"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
onepanelsdk "github.com/certimate-go/certimate/pkg/sdk3rd/1panel"
|
||||
onepanelsdk2 "github.com/certimate-go/certimate/pkg/sdk3rd/1panel/v2"
|
||||
@@ -63,7 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ServerUrl: config.ServerUrl,
|
||||
ApiVersion: config.ApiVersion,
|
||||
ApiKey: config.ApiKey,
|
||||
@@ -162,9 +162,8 @@ func (d *Deployer) deployToWebsite(ctx context.Context, certPEM, privkeyPEM stri
|
||||
default:
|
||||
if err := d.updateWebsiteCertificate(ctx, websiteId, websiteSSLId); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if i < len(websiteIds)-1 {
|
||||
xwait.DelayWithContext(ctx, time.Second*5)
|
||||
} else if i < len(websiteIds)-1 {
|
||||
xwait.DelayWithContext(ctx, 5*time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,16 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
alialb "github.com/alibabacloud-go/alb-20200616/v2/client"
|
||||
alicas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-alb/internal"
|
||||
alialb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/alb-20200616/v2/client"
|
||||
alicas "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
xwait "github.com/certimate-go/certimate/pkg/utils/wait"
|
||||
)
|
||||
@@ -56,8 +55,8 @@ type Deployer struct {
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
|
||||
type wSDKClients struct {
|
||||
ALB *internal.AlbClient
|
||||
CAS *internal.CasClient
|
||||
ALB *alialb.Client
|
||||
CAS *alicas.Client
|
||||
}
|
||||
|
||||
func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
@@ -70,7 +69,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -468,7 +467,7 @@ func (d *Deployer) waitForListenerReady(ctx context.Context, cloudListenerId str
|
||||
|
||||
d.logger.Info("waiting for aliyun alb listener's status to not be 'Configuring' ...")
|
||||
return false, nil
|
||||
}, time.Second*5); err != nil {
|
||||
}, 10*time.Second); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -476,45 +475,54 @@ func (d *Deployer) waitForListenerReady(ctx context.Context, cloudListenerId str
|
||||
}
|
||||
|
||||
func createSDKClients(accessKeyId, accessKeySecret, region string) (*wSDKClients, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/Alb
|
||||
var albEndpoint string
|
||||
switch region {
|
||||
case "", "cn-hangzhou-finance":
|
||||
albEndpoint = "alb.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
albEndpoint = fmt.Sprintf("alb.%s.aliyuncs.com", region)
|
||||
wsdk := &wSDKClients{}
|
||||
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/Alb
|
||||
var endpoint string
|
||||
switch region {
|
||||
case "", "cn-hangzhou-finance":
|
||||
endpoint = "alb.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
endpoint = fmt.Sprintf("alb.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := alialb.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.ALB = client
|
||||
}
|
||||
|
||||
albConfig := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(albEndpoint),
|
||||
}
|
||||
albClient, err := internal.NewAlbClient(albConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/cas
|
||||
var endpoint string
|
||||
if !strings.HasPrefix(region, "cn-") {
|
||||
endpoint = "cas.ap-southeast-1.aliyuncs.com"
|
||||
} else {
|
||||
endpoint = "cas.aliyuncs.com"
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
Endpoint: tea.String(endpoint),
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
}
|
||||
|
||||
client, err := alicas.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.CAS = client
|
||||
}
|
||||
|
||||
// 接入点一览 https://api.aliyun.com/product/cas
|
||||
var casEndpoint string
|
||||
if !strings.HasPrefix(region, "cn-") {
|
||||
casEndpoint = "cas.ap-southeast-1.aliyuncs.com"
|
||||
} else {
|
||||
casEndpoint = "cas.aliyuncs.com"
|
||||
}
|
||||
|
||||
casConfig := &aliopen.Config{
|
||||
Endpoint: tea.String(casEndpoint),
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
}
|
||||
casClient, err := internal.NewCasClient(casConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wSDKClients{
|
||||
ALB: albClient,
|
||||
CAS: casClient,
|
||||
}, nil
|
||||
return wsdk, nil
|
||||
}
|
||||
|
||||
@@ -8,17 +8,16 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
aliapig "github.com/alibabacloud-go/apig-20240327/v6/client"
|
||||
alicloudapi "github.com/alibabacloud-go/cloudapi-20160714/v5/client"
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-apigw/internal"
|
||||
aliapig "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/apig-20240327/v6/client"
|
||||
alicloudapi "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/cloudapi-20160714/v5/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -54,8 +53,8 @@ type Deployer struct {
|
||||
}
|
||||
|
||||
type wSDKClients struct {
|
||||
CloudNativeAPIGateway *internal.ApigClient
|
||||
TraditionalAPIGateway *internal.CloudapiClient
|
||||
CloudNativeAPIGateway *aliapig.Client
|
||||
TraditionalAPIGateway *alicloudapi.Client
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
@@ -70,7 +69,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -467,46 +466,55 @@ func (d *Deployer) findCloudNativeDomainIdByDomain(ctx context.Context, cloudGat
|
||||
}
|
||||
|
||||
func createSDKClients(accessKeyId, accessKeySecret, region string) (*wSDKClients, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/APIG
|
||||
var cloudNativeAPIGEndpoint string
|
||||
switch region {
|
||||
case "":
|
||||
cloudNativeAPIGEndpoint = "apig.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
cloudNativeAPIGEndpoint = fmt.Sprintf("apig.%s.aliyuncs.com", region)
|
||||
wsdk := &wSDKClients{}
|
||||
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/APIG
|
||||
var endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
endpoint = "apig.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
endpoint = fmt.Sprintf("apig.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := aliapig.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.CloudNativeAPIGateway = client
|
||||
}
|
||||
|
||||
cloudNativeAPIGConfig := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(cloudNativeAPIGEndpoint),
|
||||
}
|
||||
cloudNativeAPIGClient, err := internal.NewApigClient(cloudNativeAPIGConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/CloudAPI
|
||||
var endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
endpoint = "apigateway.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
endpoint = fmt.Sprintf("apigateway.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := alicloudapi.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.TraditionalAPIGateway = client
|
||||
}
|
||||
|
||||
// 接入点一览 https://api.aliyun.com/product/CloudAPI
|
||||
var traditionalAPIGEndpoint string
|
||||
switch region {
|
||||
case "":
|
||||
traditionalAPIGEndpoint = "apigateway.cn-hangzhou.aliyuncs.com"
|
||||
default:
|
||||
traditionalAPIGEndpoint = fmt.Sprintf("apigateway.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
traditionalAPIGConfig := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(traditionalAPIGEndpoint),
|
||||
}
|
||||
traditionalAPIGClient, err := internal.NewCloudapiClient(traditionalAPIGConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wSDKClients{
|
||||
CloudNativeAPIGateway: cloudNativeAPIGClient,
|
||||
TraditionalAPIGateway: traditionalAPIGClient,
|
||||
}, nil
|
||||
return wsdk, nil
|
||||
}
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
aliapig "github.com/alibabacloud-go/apig-20240327/v6/client"
|
||||
alicloudapi "github.com/alibabacloud-go/cloudapi-20160714/v5/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/apig-20240327/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ApigClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewApigClient(config *openapiutil.Config) (*ApigClient, error) {
|
||||
client := new(ApigClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *ApigClient) GetDomainWithContext(ctx context.Context, domainId *string, request *aliapig.GetDomainRequest, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *aliapig.GetDomainResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.WithStatistics) {
|
||||
query["withStatistics"] = request.WithStatistics
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Headers: headers,
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("GetDomain"),
|
||||
Version: dara.String("2024-03-27"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/v1/domains/" + dara.PercentEncode(dara.StringValue(domainId))),
|
||||
Method: dara.String("GET"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &aliapig.GetDomainResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *ApigClient) ListDomainsWithContext(ctx context.Context, request *aliapig.ListDomainsRequest, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *aliapig.ListDomainsResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.GatewayId) {
|
||||
query["gatewayId"] = request.GatewayId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.GatewayType) {
|
||||
query["gatewayType"] = request.GatewayType
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.NameLike) {
|
||||
query["nameLike"] = request.NameLike
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.PageNumber) {
|
||||
query["pageNumber"] = request.PageNumber
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.PageSize) {
|
||||
query["pageSize"] = request.PageSize
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceGroupId) {
|
||||
query["resourceGroupId"] = request.ResourceGroupId
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Headers: headers,
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("ListDomains"),
|
||||
Version: dara.String("2024-03-27"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/v1/domains"),
|
||||
Method: dara.String("GET"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &aliapig.ListDomainsResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *ApigClient) UpdateDomainWithContext(ctx context.Context, domainId *string, request *aliapig.UpdateDomainRequest, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *aliapig.UpdateDomainResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
body := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CaCertIdentifier) {
|
||||
body["caCertIdentifier"] = request.CaCertIdentifier
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.CertIdentifier) {
|
||||
body["certIdentifier"] = request.CertIdentifier
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ClientCACert) {
|
||||
body["clientCACert"] = request.ClientCACert
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ForceHttps) {
|
||||
body["forceHttps"] = request.ForceHttps
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Http2Option) {
|
||||
body["http2Option"] = request.Http2Option
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.MTLSEnabled) {
|
||||
body["mTLSEnabled"] = request.MTLSEnabled
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Protocol) {
|
||||
body["protocol"] = request.Protocol
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.TlsCipherSuitesConfig) {
|
||||
body["tlsCipherSuitesConfig"] = request.TlsCipherSuitesConfig
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.TlsMax) {
|
||||
body["tlsMax"] = request.TlsMax
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.TlsMin) {
|
||||
body["tlsMin"] = request.TlsMin
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Headers: headers,
|
||||
Body: openapiutil.ParseToMap(body),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("UpdateDomain"),
|
||||
Version: dara.String("2024-03-27"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/v1/domains/" + dara.PercentEncode(dara.StringValue(domainId))),
|
||||
Method: dara.String("PUT"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &aliapig.UpdateDomainResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/cloudapi-20160714/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CloudapiClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewCloudapiClient(config *openapiutil.Config) (*CloudapiClient, error) {
|
||||
client := new(CloudapiClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *CloudapiClient) DescribeApiGroupWithContext(ctx context.Context, request *alicloudapi.DescribeApiGroupRequest, runtime *dara.RuntimeOptions) (_result *alicloudapi.DescribeApiGroupResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.GroupId) {
|
||||
query["GroupId"] = request.GroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SecurityToken) {
|
||||
query["SecurityToken"] = request.SecurityToken
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Tag) {
|
||||
query["Tag"] = request.Tag
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("DescribeApiGroup"),
|
||||
Version: dara.String("2016-07-14"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicloudapi.DescribeApiGroupResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *CloudapiClient) SetDomainCertificateWithContext(ctx context.Context, request *alicloudapi.SetDomainCertificateRequest, runtime *dara.RuntimeOptions) (_result *alicloudapi.SetDomainCertificateResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CaCertificateBody) {
|
||||
query["CaCertificateBody"] = request.CaCertificateBody
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.CertificateBody) {
|
||||
query["CertificateBody"] = request.CertificateBody
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.CertificateName) {
|
||||
query["CertificateName"] = request.CertificateName
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.CertificatePrivateKey) {
|
||||
query["CertificatePrivateKey"] = request.CertificatePrivateKey
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ClientCertSDnPassThrough) {
|
||||
query["ClientCertSDnPassThrough"] = request.ClientCertSDnPassThrough
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.DomainName) {
|
||||
query["DomainName"] = request.DomainName
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.GroupId) {
|
||||
query["GroupId"] = request.GroupId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SecurityToken) {
|
||||
query["SecurityToken"] = request.SecurityToken
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SslOcspCacheEnable) {
|
||||
query["SslOcspCacheEnable"] = request.SslOcspCacheEnable
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SslOcspEnable) {
|
||||
query["SslOcspEnable"] = request.SslOcspEnable
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SslVerifyDepth) {
|
||||
query["SslVerifyDepth"] = request.SslVerifyDepth
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("SetDomainCertificate"),
|
||||
Version: dara.String("2016-07-14"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicloudapi.SetDomainCertificateResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -8,15 +8,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
alicas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-cas-deploy/internal"
|
||||
alicas "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
xwait "github.com/certimate-go/certimate/pkg/utils/wait"
|
||||
)
|
||||
|
||||
@@ -39,7 +38,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CasClient
|
||||
sdkClient *alicas.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -55,7 +54,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -151,14 +150,14 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
|
||||
d.logger.Info("waiting for aliyun deployment job completion ...")
|
||||
return false, nil
|
||||
}, time.Second*5); err != nil {
|
||||
}, 10*time.Second); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.CasClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alicas.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/cas
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -174,7 +173,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Cas
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewCasClient(config)
|
||||
client, err := alicas.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
alicas "github.com/alibabacloud-go/cas-20200407/v4/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/cas-20200407/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CasClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewCasClient(config *openapiutil.Config) (*CasClient, error) {
|
||||
client := new(CasClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *CasClient) Init(config *openapiutil.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *CasClient) CreateDeploymentJobWithContext(ctx context.Context, request *alicas.CreateDeploymentJobRequest, runtime *dara.RuntimeOptions) (_result *alicas.CreateDeploymentJobResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CertIds) {
|
||||
query["CertIds"] = request.CertIds
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ContactIds) {
|
||||
query["ContactIds"] = request.ContactIds
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.JobType) {
|
||||
query["JobType"] = request.JobType
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Name) {
|
||||
query["Name"] = request.Name
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ResourceIds) {
|
||||
query["ResourceIds"] = request.ResourceIds
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ScheduleTime) {
|
||||
query["ScheduleTime"] = request.ScheduleTime
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("CreateDeploymentJob"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.CreateDeploymentJobResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *CasClient) DescribeDeploymentJobWithContext(ctx context.Context, request *alicas.DescribeDeploymentJobRequest, runtime *dara.RuntimeOptions) (_result *alicas.DescribeDeploymentJobResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.JobId) {
|
||||
query["JobId"] = request.JobId
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("DescribeDeploymentJob"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.DescribeDeploymentJobResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *CasClient) ListContactWithContext(ctx context.Context, request *alicas.ListContactRequest, runtime *dara.RuntimeOptions) (_result *alicas.ListContactResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.CurrentPage) {
|
||||
query["CurrentPage"] = request.CurrentPage
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Keyword) {
|
||||
query["Keyword"] = request.Keyword
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.ShowSize) {
|
||||
query["ShowSize"] = request.ShowSize
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("ListContact"),
|
||||
Version: dara.String("2020-04-07"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alicas.ListContactResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
|
||||
@@ -8,16 +8,15 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
alicdn "github.com/alibabacloud-go/cdn-20180510/v9/client"
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-cdn/internal"
|
||||
alicdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/cdn-20180510/v9/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -40,7 +39,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CdnClient
|
||||
sdkClient *alicdn.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -250,14 +249,14 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.CdnClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*alicdn.Client, error) {
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String("cdn.aliyuncs.com"),
|
||||
}
|
||||
|
||||
client, err := internal.NewCdnClient(config)
|
||||
client, err := alicdn.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ import (
|
||||
"log/slog"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alislb "github.com/alibabacloud-go/slb-20140515/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-slb"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-slb"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-clb/internal"
|
||||
alislb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/slb-20140515/v4/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -42,7 +41,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.SlbClient
|
||||
sdkClient *alislb.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -289,7 +288,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.SlbClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alislb.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/Slb
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -309,7 +308,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Slb
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewSlbClient(config)
|
||||
client, err := alislb.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,15 +9,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alidcdn "github.com/alibabacloud-go/dcdn-20180115/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-dcdn/internal"
|
||||
alidcdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/dcdn-20180115/v4/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -40,7 +39,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.DcdnClient
|
||||
sdkClient *alidcdn.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -251,14 +250,14 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.DcdnClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*alidcdn.Client, error) {
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String("dcdn.aliyuncs.com"),
|
||||
}
|
||||
|
||||
client, err := internal.NewDcdnClient(config)
|
||||
client, err := alidcdn.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
aliddoscoo "github.com/alibabacloud-go/ddoscoo-20200101/v5/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-ddospro/internal"
|
||||
aliddoscoo "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/ddoscoo-20200101/v5/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -39,7 +38,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.DdoscooClient
|
||||
sdkClient *aliddoscoo.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -55,7 +54,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -212,7 +211,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.DdoscooClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*aliddoscoo.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/ddoscoo
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -228,7 +227,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Ddo
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewDdoscooClient(config)
|
||||
client, err := aliddoscoo.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,15 +9,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
aliesa "github.com/alibabacloud-go/esa-20240910/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-esa-saas/internal"
|
||||
aliesa "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/esa-20240910/v2/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -42,7 +41,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.EsaClient
|
||||
sdkClient *aliesa.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -276,7 +275,7 @@ func (d *Deployer) updateHostnameCertificate(ctx context.Context, cloudHostnameI
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.EsaClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*aliesa.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/ESA
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -292,7 +291,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Esa
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewEsaClient(config)
|
||||
client, err := aliesa.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,15 +9,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
aliesa "github.com/alibabacloud-go/esa-20240910/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-esa/internal"
|
||||
aliesa "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/esa-20240910/v2/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -36,7 +35,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.EsaClient
|
||||
sdkClient *aliesa.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -119,7 +118,7 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.EsaClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*aliesa.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/ESA
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -135,7 +134,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Esa
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewEsaClient(config)
|
||||
client, err := aliesa.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
aliesa "github.com/alibabacloud-go/esa-20240910/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/esa-20240910/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type EsaClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewEsaClient(config *openapiutil.Config) (*EsaClient, error) {
|
||||
client := new(EsaClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *EsaClient) Init(config *openapiutil.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *EsaClient) SetCertificateWithContext(ctx context.Context, request *aliesa.SetCertificateRequest, runtime *dara.RuntimeOptions) (_result *aliesa.SetCertificateResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
if !dara.IsNil(request.KeyServerId) {
|
||||
query["KeyServerId"] = request.KeyServerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.OwnerId) {
|
||||
query["OwnerId"] = request.OwnerId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SecurityToken) {
|
||||
query["SecurityToken"] = request.SecurityToken
|
||||
}
|
||||
|
||||
body := map[string]interface{}{}
|
||||
if !dara.IsNil(request.CasId) {
|
||||
body["CasId"] = request.CasId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Certificate) {
|
||||
body["Certificate"] = request.Certificate
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Id) {
|
||||
body["Id"] = request.Id
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Name) {
|
||||
body["Name"] = request.Name
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.PrivateKey) {
|
||||
body["PrivateKey"] = request.PrivateKey
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Region) {
|
||||
body["Region"] = request.Region
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.SiteId) {
|
||||
body["SiteId"] = request.SiteId
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Type) {
|
||||
body["Type"] = request.Type
|
||||
}
|
||||
|
||||
req := &openapiutil.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
Body: openapiutil.ParseToMap(body),
|
||||
}
|
||||
params := &openapiutil.Params{
|
||||
Action: dara.String("SetCertificate"),
|
||||
Version: dara.String("2024-09-10"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/"),
|
||||
Method: dara.String("POST"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("RPC"),
|
||||
ReqBodyType: dara.String("formData"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &aliesa.SetCertificateResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -9,14 +9,13 @@ import (
|
||||
"time"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alifc3 "github.com/alibabacloud-go/fc-20230330/v4/client"
|
||||
alifc2 "github.com/alibabacloud-go/fc-open-20210406/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-fc/internal"
|
||||
alifc "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/fc-20230330/v4/client"
|
||||
alifcopen "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/fc-open-20210406/v2/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -48,8 +47,8 @@ type Deployer struct {
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
|
||||
type wSDKClients struct {
|
||||
FC2 *internal.FcopenClient
|
||||
FC3 *internal.FcClient
|
||||
FC2 *alifcopen.Client
|
||||
FC3 *alifc.Client
|
||||
}
|
||||
|
||||
func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
@@ -271,7 +270,7 @@ func (d *Deployer) getFC3AllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
listCustomDomainsReq := &alifc3.ListCustomDomainsRequest{
|
||||
listCustomDomainsReq := &alifc.ListCustomDomainsRequest{
|
||||
NextToken: listCustomDomainsNextToken,
|
||||
Limit: tea.Int32(100),
|
||||
}
|
||||
@@ -312,7 +311,7 @@ func (d *Deployer) getFC2AllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
listCustomDomainsReq := &alifc2.ListCustomDomainsRequest{
|
||||
listCustomDomainsReq := &alifcopen.ListCustomDomainsRequest{
|
||||
NextToken: listCustomDomainsNextToken,
|
||||
Limit: tea.Int32(100),
|
||||
}
|
||||
@@ -355,9 +354,9 @@ func (d *Deployer) updateFC3DomainCertificate(ctx context.Context, domain string
|
||||
|
||||
// 更新自定义域名
|
||||
// REF: https://help.aliyun.com/zh/functioncompute/fc-3-0/developer-reference/api-fc-2023-03-30-updatecustomdomain
|
||||
updateCustomDomainReq := &alifc3.UpdateCustomDomainRequest{
|
||||
Body: &alifc3.UpdateCustomDomainInput{
|
||||
CertConfig: &alifc3.CertConfig{
|
||||
updateCustomDomainReq := &alifc.UpdateCustomDomainRequest{
|
||||
Body: &alifc.UpdateCustomDomainInput{
|
||||
CertConfig: &alifc.CertConfig{
|
||||
CertName: tea.String(fmt.Sprintf("certimate-%d", time.Now().UnixMilli())),
|
||||
Certificate: tea.String(certPEM),
|
||||
PrivateKey: tea.String(privkeyPEM),
|
||||
@@ -393,8 +392,8 @@ func (d *Deployer) updateFC2DomainCertificate(ctx context.Context, domain string
|
||||
|
||||
// 更新自定义域名
|
||||
// REF: https://help.aliyun.com/zh/functioncompute/fc-2-0/developer-reference/api-fc-open-2021-04-06-updatecustomdomain
|
||||
updateCustomDomainReq := &alifc2.UpdateCustomDomainRequest{
|
||||
CertConfig: &alifc2.CertConfig{
|
||||
updateCustomDomainReq := &alifcopen.UpdateCustomDomainRequest{
|
||||
CertConfig: &alifcopen.CertConfig{
|
||||
CertName: tea.String(fmt.Sprintf("certimate-%d", time.Now().UnixMilli())),
|
||||
Certificate: tea.String(certPEM),
|
||||
PrivateKey: tea.String(privkeyPEM),
|
||||
@@ -415,50 +414,59 @@ func (d *Deployer) updateFC2DomainCertificate(ctx context.Context, domain string
|
||||
}
|
||||
|
||||
func createSDKClients(accessKeyId, accessKeySecret, region string) (*wSDKClients, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/FC-Open
|
||||
var fc2Endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
fc2Endpoint = "fc.aliyuncs.com"
|
||||
case "cn-hangzhou-finance":
|
||||
fc2Endpoint = fmt.Sprintf("%s.fc.aliyuncs.com", region)
|
||||
default:
|
||||
fc2Endpoint = fmt.Sprintf("fc.%s.aliyuncs.com", region)
|
||||
wsdk := &wSDKClients{}
|
||||
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/FC-Open
|
||||
var endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
endpoint = "fc.aliyuncs.com"
|
||||
case "cn-hangzhou-finance":
|
||||
endpoint = fmt.Sprintf("%s.fc.aliyuncs.com", region)
|
||||
default:
|
||||
endpoint = fmt.Sprintf("fc.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := alifcopen.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.FC2 = client
|
||||
}
|
||||
|
||||
fc2Config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(fc2Endpoint),
|
||||
}
|
||||
fc2Client, err := internal.NewFcopenClient(fc2Config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
{
|
||||
// 接入点一览 https://api.aliyun.com/product/FC
|
||||
var endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
endpoint = "fcv3.cn-hangzhou.aliyuncs.com"
|
||||
case "me-central-1", "cn-hangzhou-finance", "cn-shanghai-finance-1", "cn-heyuan-acdr-1":
|
||||
endpoint = fmt.Sprintf("%s.fc.aliyuncs.com", region)
|
||||
default:
|
||||
endpoint = fmt.Sprintf("fcv3.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := alifc.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wsdk.FC3 = client
|
||||
}
|
||||
|
||||
// 接入点一览 https://api.aliyun.com/product/FC
|
||||
var fc3Endpoint string
|
||||
switch region {
|
||||
case "":
|
||||
fc3Endpoint = "fcv3.cn-hangzhou.aliyuncs.com"
|
||||
case "me-central-1", "cn-hangzhou-finance", "cn-shanghai-finance-1", "cn-heyuan-acdr-1":
|
||||
fc3Endpoint = fmt.Sprintf("%s.fc.aliyuncs.com", region)
|
||||
default:
|
||||
fc3Endpoint = fmt.Sprintf("fcv3.%s.aliyuncs.com", region)
|
||||
}
|
||||
|
||||
fc3Config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
AccessKeySecret: tea.String(accessKeySecret),
|
||||
Endpoint: tea.String(fc3Endpoint),
|
||||
}
|
||||
fc3Client, err := internal.NewFcClient(fc3Config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wSDKClients{
|
||||
FC2: fc2Client,
|
||||
FC3: fc3Client,
|
||||
}, nil
|
||||
return wsdk, nil
|
||||
}
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
openapiutilv2 "github.com/alibabacloud-go/darabonba-openapi/v2/utils"
|
||||
alifc "github.com/alibabacloud-go/fc-20230330/v4/client"
|
||||
alifcopen "github.com/alibabacloud-go/fc-open-20210406/v2/client"
|
||||
openapiutil "github.com/alibabacloud-go/openapi-util/service"
|
||||
util "github.com/alibabacloud-go/tea-utils/v2/service"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/fc-20230330/blob/master/client/client_context_func.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type FcClient struct {
|
||||
openapi.Client
|
||||
DisableSDKError *bool
|
||||
}
|
||||
|
||||
func NewFcClient(config *openapiutilv2.Config) (*FcClient, error) {
|
||||
client := new(FcClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *FcClient) Init(config *openapiutilv2.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *FcClient) GetCustomDomainWithContext(ctx context.Context, domainName *string, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *alifc.GetCustomDomainResponse, _err error) {
|
||||
req := &openapiutilv2.OpenApiRequest{
|
||||
Headers: headers,
|
||||
}
|
||||
params := &openapiutilv2.Params{
|
||||
Action: dara.String("GetCustomDomain"),
|
||||
Version: dara.String("2023-03-30"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/2023-03-30/custom-domains/" + dara.PercentEncode(dara.StringValue(domainName))),
|
||||
Method: dara.String("GET"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alifc.GetCustomDomainResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcClient) ListCustomDomainsWithContext(ctx context.Context, request *alifc.ListCustomDomainsRequest, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *alifc.ListCustomDomainsResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !dara.IsNil(request.Limit) {
|
||||
query["limit"] = request.Limit
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.NextToken) {
|
||||
query["nextToken"] = request.NextToken
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Prefix) {
|
||||
query["prefix"] = request.Prefix
|
||||
}
|
||||
|
||||
req := &openapiutilv2.OpenApiRequest{
|
||||
Headers: headers,
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapiutilv2.Params{
|
||||
Action: dara.String("ListCustomDomains"),
|
||||
Version: dara.String("2023-03-30"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/2023-03-30/custom-domains"),
|
||||
Method: dara.String("GET"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alifc.ListCustomDomainsResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcClient) UpdateCustomDomainWithContext(ctx context.Context, domainName *string, request *alifc.UpdateCustomDomainRequest, headers map[string]*string, runtime *dara.RuntimeOptions) (_result *alifc.UpdateCustomDomainResponse, _err error) {
|
||||
_err = request.Validate()
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
req := &openapiutilv2.OpenApiRequest{
|
||||
Headers: headers,
|
||||
Body: openapiutil.ParseToMap(request.Body),
|
||||
}
|
||||
params := &openapiutilv2.Params{
|
||||
Action: dara.String("UpdateCustomDomain"),
|
||||
Version: dara.String("2023-03-30"),
|
||||
Protocol: dara.String("HTTPS"),
|
||||
Pathname: dara.String("/2023-03-30/custom-domains/" + dara.PercentEncode(dara.StringValue(domainName))),
|
||||
Method: dara.String("PUT"),
|
||||
AuthType: dara.String("AK"),
|
||||
Style: dara.String("ROA"),
|
||||
ReqBodyType: dara.String("json"),
|
||||
BodyType: dara.String("json"),
|
||||
}
|
||||
_result = &alifc.UpdateCustomDomainResponse{}
|
||||
_body, _err := client.CallApiWithCtx(ctx, params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = dara.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/fc-open-20210406/blob/master/client/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type FcopenClient struct {
|
||||
openapi.Client
|
||||
}
|
||||
|
||||
func NewFcopenClient(config *openapi.Config) (*FcopenClient, error) {
|
||||
client := new(FcopenClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) Init(config *openapi.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *FcopenClient) GetCustomDomain(domainName *string) (_result *alifcopen.GetCustomDomainResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
headers := &alifcopen.GetCustomDomainHeaders{}
|
||||
_result = &alifcopen.GetCustomDomainResponse{}
|
||||
_body, _err := client.GetCustomDomainWithOptions(domainName, headers, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) GetCustomDomainWithOptions(domainName *string, headers *alifcopen.GetCustomDomainHeaders, runtime *util.RuntimeOptions) (_result *alifcopen.GetCustomDomainResponse, _err error) {
|
||||
realHeaders := make(map[string]*string)
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.CommonHeaders)) {
|
||||
realHeaders = headers.CommonHeaders
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcAccountId)) {
|
||||
realHeaders["X-Fc-Account-Id"] = util.ToJSONString(headers.XFcAccountId)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcDate)) {
|
||||
realHeaders["X-Fc-Date"] = util.ToJSONString(headers.XFcDate)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcTraceId)) {
|
||||
realHeaders["X-Fc-Trace-Id"] = util.ToJSONString(headers.XFcTraceId)
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Headers: realHeaders,
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("GetCustomDomain"),
|
||||
Version: tea.String("2021-04-06"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/2021-04-06/custom-domains/" + tea.StringValue(openapiutil.GetEncodeParam(domainName))),
|
||||
Method: tea.String("GET"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("ROA"),
|
||||
ReqBodyType: tea.String("json"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &alifcopen.GetCustomDomainResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) ListCustomDomains(request *alifcopen.ListCustomDomainsRequest) (_result *alifcopen.ListCustomDomainsResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
headers := &alifcopen.ListCustomDomainsHeaders{}
|
||||
_result = &alifcopen.ListCustomDomainsResponse{}
|
||||
_body, _err := client.ListCustomDomainsWithOptions(request, headers, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) ListCustomDomainsWithOptions(request *alifcopen.ListCustomDomainsRequest, headers *alifcopen.ListCustomDomainsHeaders, runtime *util.RuntimeOptions) (_result *alifcopen.ListCustomDomainsResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Limit)) {
|
||||
query["limit"] = request.Limit
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.NextToken)) {
|
||||
query["nextToken"] = request.NextToken
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Prefix)) {
|
||||
query["prefix"] = request.Prefix
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.StartKey)) {
|
||||
query["startKey"] = request.StartKey
|
||||
}
|
||||
|
||||
realHeaders := make(map[string]*string)
|
||||
if !tea.BoolValue(util.IsUnset(headers.CommonHeaders)) {
|
||||
realHeaders = headers.CommonHeaders
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcAccountId)) {
|
||||
realHeaders["X-Fc-Account-Id"] = util.ToJSONString(headers.XFcAccountId)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcDate)) {
|
||||
realHeaders["X-Fc-Date"] = util.ToJSONString(headers.XFcDate)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcTraceId)) {
|
||||
realHeaders["X-Fc-Trace-Id"] = util.ToJSONString(headers.XFcTraceId)
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Headers: realHeaders,
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("ListCustomDomains"),
|
||||
Version: tea.String("2021-04-06"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/2021-04-06/custom-domains"),
|
||||
Method: tea.String("GET"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("ROA"),
|
||||
ReqBodyType: tea.String("json"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &alifcopen.ListCustomDomainsResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) UpdateCustomDomain(domainName *string, request *alifcopen.UpdateCustomDomainRequest) (_result *alifcopen.UpdateCustomDomainResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
headers := &alifcopen.UpdateCustomDomainHeaders{}
|
||||
_result = &alifcopen.UpdateCustomDomainResponse{}
|
||||
_body, _err := client.UpdateCustomDomainWithOptions(domainName, request, headers, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *FcopenClient) UpdateCustomDomainWithOptions(domainName *string, request *alifcopen.UpdateCustomDomainRequest, headers *alifcopen.UpdateCustomDomainHeaders, runtime *util.RuntimeOptions) (_result *alifcopen.UpdateCustomDomainResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
body := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.CertConfig)) {
|
||||
body["certConfig"] = request.CertConfig
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Protocol)) {
|
||||
body["protocol"] = request.Protocol
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RouteConfig)) {
|
||||
body["routeConfig"] = request.RouteConfig
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.TlsConfig)) {
|
||||
body["tlsConfig"] = request.TlsConfig
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.WafConfig)) {
|
||||
body["wafConfig"] = request.WafConfig
|
||||
}
|
||||
|
||||
realHeaders := make(map[string]*string)
|
||||
if !tea.BoolValue(util.IsUnset(headers.CommonHeaders)) {
|
||||
realHeaders = headers.CommonHeaders
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcAccountId)) {
|
||||
realHeaders["X-Fc-Account-Id"] = util.ToJSONString(headers.XFcAccountId)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcDate)) {
|
||||
realHeaders["X-Fc-Date"] = util.ToJSONString(headers.XFcDate)
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(headers.XFcTraceId)) {
|
||||
realHeaders["X-Fc-Trace-Id"] = util.ToJSONString(headers.XFcTraceId)
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Headers: realHeaders,
|
||||
Body: openapiutil.ParseToMap(body),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("UpdateCustomDomain"),
|
||||
Version: tea.String("2021-04-06"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/2021-04-06/custom-domains/" + tea.StringValue(openapiutil.GetEncodeParam(domainName))),
|
||||
Method: tea.String("PUT"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("ROA"),
|
||||
ReqBodyType: tea.String("json"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &alifcopen.UpdateCustomDomainResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
aliga "github.com/alibabacloud-go/ga-20191120/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-ga/internal"
|
||||
aliga "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/ga-20191120/v4/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -40,7 +40,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.GaClient
|
||||
sdkClient *aliga.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -135,7 +135,7 @@ func (d *Deployer) deployToAccelerator(ctx context.Context, cloudCertId string)
|
||||
PageNumber: tea.Int32(int32(listListenersPageNumber)),
|
||||
PageSize: tea.Int32(int32(listListenersPageSize)),
|
||||
}
|
||||
listListenersResp, err := d.sdkClient.ListListeners(listListenersReq)
|
||||
listListenersResp, err := d.sdkClient.ListListenersWithContext(ctx, listListenersReq, &dara.RuntimeOptions{})
|
||||
d.logger.Debug("sdk request 'ga.ListListeners'", slog.Any("request", listListenersReq), slog.Any("response", listListenersResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'ga.ListListeners': %w", err)
|
||||
@@ -214,7 +214,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat
|
||||
NextToken: listListenerCertificatesNextToken,
|
||||
MaxResults: tea.Int32(20),
|
||||
}
|
||||
listListenerCertificatesResp, err := d.sdkClient.ListListenerCertificates(listListenerCertificatesReq)
|
||||
listListenerCertificatesResp, err := d.sdkClient.ListListenerCertificatesWithContext(ctx, listListenerCertificatesReq, &dara.RuntimeOptions{})
|
||||
d.logger.Debug("sdk request 'ga.ListListenerCertificates'", slog.Any("request", listListenerCertificatesReq), slog.Any("response", listListenerCertificatesResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'ga.ListListenerCertificates': %w", err)
|
||||
@@ -255,7 +255,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat
|
||||
Id: tea.String(cloudCertId),
|
||||
}},
|
||||
}
|
||||
updateListenerResp, err := d.sdkClient.UpdateListener(updateListenerReq)
|
||||
updateListenerResp, err := d.sdkClient.UpdateListenerWithContext(ctx, updateListenerReq, &dara.RuntimeOptions{})
|
||||
d.logger.Debug("sdk request 'ga.UpdateListener'", slog.Any("request", updateListenerReq), slog.Any("response", updateListenerResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'ga.UpdateListener': %w", err)
|
||||
@@ -281,7 +281,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat
|
||||
CertificateId: tea.String(cloudCertId),
|
||||
Domain: tea.String(d.config.Domain),
|
||||
}
|
||||
updateAdditionalCertificateWithListenerResp, err := d.sdkClient.UpdateAdditionalCertificateWithListener(updateAdditionalCertificateWithListenerReq)
|
||||
updateAdditionalCertificateWithListenerResp, err := d.sdkClient.UpdateAdditionalCertificateWithListenerWithContext(ctx, updateAdditionalCertificateWithListenerReq, &dara.RuntimeOptions{})
|
||||
d.logger.Debug("sdk request 'ga.UpdateAdditionalCertificateWithListener'", slog.Any("request", updateAdditionalCertificateWithListenerReq), slog.Any("response", updateAdditionalCertificateWithListenerResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'ga.UpdateAdditionalCertificateWithListener': %w", err)
|
||||
@@ -298,7 +298,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat
|
||||
Domain: tea.String(d.config.Domain),
|
||||
}},
|
||||
}
|
||||
associateAdditionalCertificatesWithListenerResp, err := d.sdkClient.AssociateAdditionalCertificatesWithListener(associateAdditionalCertificatesWithListenerReq)
|
||||
associateAdditionalCertificatesWithListenerResp, err := d.sdkClient.AssociateAdditionalCertificatesWithListenerWithContext(ctx, associateAdditionalCertificatesWithListenerReq, &dara.RuntimeOptions{})
|
||||
d.logger.Debug("sdk request 'ga.AssociateAdditionalCertificatesWithListener'", slog.Any("request", associateAdditionalCertificatesWithListenerReq), slog.Any("response", associateAdditionalCertificatesWithListenerResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'ga.AssociateAdditionalCertificatesWithListener': %w", err)
|
||||
@@ -309,7 +309,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudAccelerat
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.GaClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*aliga.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/Ga
|
||||
config := &aliopen.Config{
|
||||
AccessKeyId: tea.String(accessKeyId),
|
||||
@@ -317,7 +317,7 @@ func createSDKClient(accessKeyId, accessKeySecret string) (*internal.GaClient, e
|
||||
Endpoint: tea.String("ga.cn-hangzhou.aliyuncs.com"),
|
||||
}
|
||||
|
||||
client, err := internal.NewGaClient(config)
|
||||
client, err := aliga.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,396 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
aliga "github.com/alibabacloud-go/ga-20191120/v4/client"
|
||||
openapiutil "github.com/alibabacloud-go/openapi-util/service"
|
||||
util "github.com/alibabacloud-go/tea-utils/v2/service"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/alibabacloud-go/ga-20191120/blob/master/client/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type GaClient struct {
|
||||
openapi.Client
|
||||
}
|
||||
|
||||
func NewGaClient(config *openapi.Config) (*GaClient, error) {
|
||||
client := new(GaClient)
|
||||
err := client.Init(config)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (client *GaClient) Init(config *openapi.Config) (_err error) {
|
||||
_err = client.Client.Init(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
_err = client.CheckConfig(config)
|
||||
if _err != nil {
|
||||
return _err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *GaClient) AssociateAdditionalCertificatesWithListenerWithOptions(request *aliga.AssociateAdditionalCertificatesWithListenerRequest, runtime *util.RuntimeOptions) (_result *aliga.AssociateAdditionalCertificatesWithListenerResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.AcceleratorId)) {
|
||||
query["AcceleratorId"] = request.AcceleratorId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Certificates)) {
|
||||
query["Certificates"] = request.Certificates
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ClientToken)) {
|
||||
query["ClientToken"] = request.ClientToken
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ListenerId)) {
|
||||
query["ListenerId"] = request.ListenerId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RegionId)) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("AssociateAdditionalCertificatesWithListener"),
|
||||
Version: tea.String("2019-11-20"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/"),
|
||||
Method: tea.String("POST"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("RPC"),
|
||||
ReqBodyType: tea.String("formData"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &aliga.AssociateAdditionalCertificatesWithListenerResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) AssociateAdditionalCertificatesWithListener(request *aliga.AssociateAdditionalCertificatesWithListenerRequest) (_result *aliga.AssociateAdditionalCertificatesWithListenerResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_result = &aliga.AssociateAdditionalCertificatesWithListenerResponse{}
|
||||
_body, _err := client.AssociateAdditionalCertificatesWithListenerWithOptions(request, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) ListListenersWithOptions(request *aliga.ListListenersRequest, runtime *util.RuntimeOptions) (_result *aliga.ListListenersResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.AcceleratorId)) {
|
||||
query["AcceleratorId"] = request.AcceleratorId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.PageNumber)) {
|
||||
query["PageNumber"] = request.PageNumber
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.PageSize)) {
|
||||
query["PageSize"] = request.PageSize
|
||||
}
|
||||
|
||||
if !dara.IsNil(request.Protocol) {
|
||||
query["Protocol"] = request.Protocol
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RegionId)) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("ListListeners"),
|
||||
Version: tea.String("2019-11-20"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/"),
|
||||
Method: tea.String("POST"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("RPC"),
|
||||
ReqBodyType: tea.String("formData"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &aliga.ListListenersResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) ListListeners(request *aliga.ListListenersRequest) (_result *aliga.ListListenersResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_result = &aliga.ListListenersResponse{}
|
||||
_body, _err := client.ListListenersWithOptions(request, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) ListListenerCertificatesWithOptions(request *aliga.ListListenerCertificatesRequest, runtime *util.RuntimeOptions) (_result *aliga.ListListenerCertificatesResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.AcceleratorId)) {
|
||||
query["AcceleratorId"] = request.AcceleratorId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ListenerId)) {
|
||||
query["ListenerId"] = request.ListenerId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.MaxResults)) {
|
||||
query["MaxResults"] = request.MaxResults
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.NextToken)) {
|
||||
query["NextToken"] = request.NextToken
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RegionId)) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Role)) {
|
||||
query["Role"] = request.Role
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("ListListenerCertificates"),
|
||||
Version: tea.String("2019-11-20"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/"),
|
||||
Method: tea.String("POST"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("RPC"),
|
||||
ReqBodyType: tea.String("formData"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &aliga.ListListenerCertificatesResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) ListListenerCertificates(request *aliga.ListListenerCertificatesRequest) (_result *aliga.ListListenerCertificatesResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_result = &aliga.ListListenerCertificatesResponse{}
|
||||
_body, _err := client.ListListenerCertificatesWithOptions(request, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) UpdateAdditionalCertificateWithListenerWithOptions(request *aliga.UpdateAdditionalCertificateWithListenerRequest, runtime *util.RuntimeOptions) (_result *aliga.UpdateAdditionalCertificateWithListenerResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.AcceleratorId)) {
|
||||
query["AcceleratorId"] = request.AcceleratorId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.CertificateId)) {
|
||||
query["CertificateId"] = request.CertificateId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ClientToken)) {
|
||||
query["ClientToken"] = request.ClientToken
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Domain)) {
|
||||
query["Domain"] = request.Domain
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.DryRun)) {
|
||||
query["DryRun"] = request.DryRun
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ListenerId)) {
|
||||
query["ListenerId"] = request.ListenerId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RegionId)) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("UpdateAdditionalCertificateWithListener"),
|
||||
Version: tea.String("2019-11-20"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/"),
|
||||
Method: tea.String("POST"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("RPC"),
|
||||
ReqBodyType: tea.String("formData"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &aliga.UpdateAdditionalCertificateWithListenerResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) UpdateAdditionalCertificateWithListener(request *aliga.UpdateAdditionalCertificateWithListenerRequest) (_result *aliga.UpdateAdditionalCertificateWithListenerResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_result = &aliga.UpdateAdditionalCertificateWithListenerResponse{}
|
||||
_body, _err := client.UpdateAdditionalCertificateWithListenerWithOptions(request, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) UpdateListenerWithOptions(request *aliga.UpdateListenerRequest, runtime *util.RuntimeOptions) (_result *aliga.UpdateListenerResponse, _err error) {
|
||||
_err = util.ValidateModel(request)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
query := map[string]interface{}{}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.BackendPorts)) {
|
||||
query["BackendPorts"] = request.BackendPorts
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Certificates)) {
|
||||
query["Certificates"] = request.Certificates
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ClientAffinity)) {
|
||||
query["ClientAffinity"] = request.ClientAffinity
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ClientToken)) {
|
||||
query["ClientToken"] = request.ClientToken
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Description)) {
|
||||
query["Description"] = request.Description
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.HttpVersion)) {
|
||||
query["HttpVersion"] = request.HttpVersion
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.IdleTimeout)) {
|
||||
query["IdleTimeout"] = request.IdleTimeout
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ListenerId)) {
|
||||
query["ListenerId"] = request.ListenerId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Name)) {
|
||||
query["Name"] = request.Name
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.PortRanges)) {
|
||||
query["PortRanges"] = request.PortRanges
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.Protocol)) {
|
||||
query["Protocol"] = request.Protocol
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.ProxyProtocol)) {
|
||||
query["ProxyProtocol"] = request.ProxyProtocol
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RegionId)) {
|
||||
query["RegionId"] = request.RegionId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.RequestTimeout)) {
|
||||
query["RequestTimeout"] = request.RequestTimeout
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.SecurityPolicyId)) {
|
||||
query["SecurityPolicyId"] = request.SecurityPolicyId
|
||||
}
|
||||
|
||||
if !tea.BoolValue(util.IsUnset(request.XForwardedForConfig)) {
|
||||
query["XForwardedForConfig"] = request.XForwardedForConfig
|
||||
}
|
||||
|
||||
req := &openapi.OpenApiRequest{
|
||||
Query: openapiutil.Query(query),
|
||||
}
|
||||
params := &openapi.Params{
|
||||
Action: tea.String("UpdateListener"),
|
||||
Version: tea.String("2019-11-20"),
|
||||
Protocol: tea.String("HTTPS"),
|
||||
Pathname: tea.String("/"),
|
||||
Method: tea.String("POST"),
|
||||
AuthType: tea.String("AK"),
|
||||
Style: tea.String("RPC"),
|
||||
ReqBodyType: tea.String("formData"),
|
||||
BodyType: tea.String("json"),
|
||||
}
|
||||
_result = &aliga.UpdateListenerResponse{}
|
||||
_body, _err := client.CallApi(params, req, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_err = tea.Convert(_body, &_result)
|
||||
return _result, _err
|
||||
}
|
||||
|
||||
func (client *GaClient) UpdateListener(request *aliga.UpdateListenerRequest) (_result *aliga.UpdateListenerResponse, _err error) {
|
||||
runtime := &util.RuntimeOptions{}
|
||||
_result = &aliga.UpdateListenerResponse{}
|
||||
_body, _err := client.UpdateListenerWithOptions(request, runtime)
|
||||
if _err != nil {
|
||||
return _result, _err
|
||||
}
|
||||
_result = _body
|
||||
return _result, _err
|
||||
}
|
||||
@@ -9,13 +9,12 @@ import (
|
||||
"time"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alilive "github.com/alibabacloud-go/live-20161101/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-live/internal"
|
||||
alilive "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/live-20161101/v2/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -38,7 +37,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.LiveClient
|
||||
sdkClient *alilive.Client
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
@@ -216,7 +215,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.LiveClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alilive.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/live
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -239,7 +238,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Liv
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewLiveClient(config)
|
||||
client, err := alilive.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ import (
|
||||
"strings"
|
||||
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
alinlb "github.com/alibabacloud-go/nlb-20220430/v4/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-nlb/internal"
|
||||
alinlb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/nlb-20220430/v4/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -41,7 +40,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.NlbClient
|
||||
sdkClient *alinlb.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -235,7 +234,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.NlbClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alinlb.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/Nlb
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -251,7 +250,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Nlb
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewNlbClient(config)
|
||||
client, err := alinlb.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -11,13 +11,12 @@ import (
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
alivod "github.com/alibabacloud-go/vod-20170321/v4/client"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-vod/internal"
|
||||
alivod "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/vod-20170321/v4/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -40,7 +39,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.VodClient
|
||||
sdkClient *alivod.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -245,7 +244,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.VodClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*alivod.Client, error) {
|
||||
// 接入点一览 https://api.aliyun.com/product/vod
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -261,7 +260,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Vod
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewVodClient(config)
|
||||
client, err := alivod.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -11,13 +11,12 @@ import (
|
||||
aliopen "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
aliwaf "github.com/alibabacloud-go/waf-openapi-20211001/v7/client"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aliyun-cas"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/aliyun-waf/internal"
|
||||
aliwaf "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/alibabacloud-go/waf-openapi-20211001/v7/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -52,7 +51,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.WafClient
|
||||
sdkClient *aliwaf.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
ResourceGroupId: config.ResourceGroupId,
|
||||
@@ -389,7 +388,7 @@ func (d *Deployer) deployToWAF3WithCNAME(ctx context.Context, cloudCertId string
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret, region string) (*aliwaf.Client, error) {
|
||||
// 接入点一览:https://api.aliyun.com/product/waf-openapi
|
||||
var endpoint string
|
||||
switch region {
|
||||
@@ -405,7 +404,7 @@ func createSDKClient(accessKeyId, accessKeySecret, region string) (*internal.Waf
|
||||
Endpoint: tea.String(endpoint),
|
||||
}
|
||||
|
||||
client, err := internal.NewWafClient(config)
|
||||
client, err := aliwaf.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
Region: config.Region,
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/service/cloudfront/types"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgracm "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
|
||||
mcertmgriam "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
|
||||
certmgrimplacm "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-acm"
|
||||
certmgrimpliam "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
var pcertmgr certmgr.Provider
|
||||
switch config.CertificateSource {
|
||||
case CERTIFICATE_SOURCE_ACM:
|
||||
pcertmgr, err = mcertmgracm.NewCertmgr(&mcertmgracm.CertmgrConfig{
|
||||
pcertmgr, err = certmgrimplacm.NewCertmgr(&certmgrimplacm.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
Region: config.Region,
|
||||
@@ -64,7 +64,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
}
|
||||
|
||||
case CERTIFICATE_SOURCE_IAM:
|
||||
pcertmgr, err = mcertmgriam.NewCertmgr(&mcertmgriam.CertmgrConfig{
|
||||
pcertmgr, err = certmgrimpliam.NewCertmgr(&certmgrimpliam.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
Region: config.Region,
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/aws-iam"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
Region: config.Region,
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/azure-keyvault"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/azure-keyvault"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
TenantId: config.TenantId,
|
||||
ClientId: config.ClientId,
|
||||
ClientSecret: config.ClientSecret,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baiducloud-cert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baishan-cdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/baishan-cdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
baishansdk "github.com/certimate-go/certimate/pkg/sdk3rd/baishan"
|
||||
)
|
||||
@@ -49,7 +49,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ApiToken: config.ApiToken,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -115,9 +115,8 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
default:
|
||||
if err := d.updateSiteCertificate(ctx, d.config.SiteType, siteName, certPEM, privkeyPEM); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, time.Second*5)
|
||||
} else if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, 5*time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,8 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
default:
|
||||
if err := d.updateSiteCertificate(ctx, d.config.SiteType, siteName, certPEM, privkeyPEM); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, time.Second*5)
|
||||
} else if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, 5*time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,8 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
default:
|
||||
if err := d.updateSiteCertificate(ctx, siteName, d.config.SitePort, certPEM, privkeyPEM); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, time.Second*5)
|
||||
} else if i < len(d.config.SiteNames)-1 {
|
||||
xwait.DelayWithContext(ctx, 5*time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
bp "github.com/volcengine/volcengine-go-sdk/volcengine"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-cdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/byteplus-cdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
@@ -46,7 +46,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
client.Client.SetAccessKey(config.AccessKey)
|
||||
client.Client.SetSecretKey(config.SecretKey)
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-ao"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-ao"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
ctyunao "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/ao"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -48,7 +48,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
ctyuncdn "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/cdn"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -47,7 +47,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cms"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-cms"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-elb"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-elb"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
ctyunelb "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/elb"
|
||||
)
|
||||
@@ -51,7 +51,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
RegionId: config.RegionId,
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-icdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-icdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
ctyunicdn "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/icdn"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -47,7 +47,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-lvdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/ctcccloud-lvdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
ctyunlvdn "github.com/certimate-go/certimate/pkg/sdk3rd/ctyun/lvdn"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -46,7 +46,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dogecloud"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dogecloud"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
dogesdk "github.com/certimate-go/certimate/pkg/sdk3rd/dogecloud"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -47,7 +47,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dokploy"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/dokploy"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ServerUrl: config.ServerUrl,
|
||||
ApiKey: config.ApiKey,
|
||||
AllowInsecureConnections: config.AllowInsecureConnections,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/G-Core/gcorelabscdn-go/sslcerts"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/gcore-cdn"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/gcore-cdn"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
gcoresdk "github.com/certimate-go/certimate/pkg/sdk3rd/gcore"
|
||||
)
|
||||
@@ -52,7 +52,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ApiToken: config.ApiToken,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hcaad "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1"
|
||||
hcaadmodelv1 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1/model"
|
||||
hcaadregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1/region"
|
||||
hcaadmodelv2 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v2/model"
|
||||
hwaadmodelv1 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1/model"
|
||||
hwaadregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1/region"
|
||||
hwaadmodelv2 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v2/model"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-aad/internal"
|
||||
hwaadv1 "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1"
|
||||
hwaadv2 "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v2"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -36,30 +36,32 @@ type DeployerConfig struct {
|
||||
}
|
||||
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.AadClient
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClients *wSDKClients
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
|
||||
type wSDKClients struct {
|
||||
AADv1 *hwaadv1.AadClient
|
||||
AADv2 *hwaadv2.AadClient
|
||||
}
|
||||
|
||||
func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
if config == nil {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
client, err := createSDKClient(
|
||||
config.AccessKeyId,
|
||||
config.SecretAccessKey,
|
||||
)
|
||||
clients, err := createSDKClients(config.AccessKeyId, config.SecretAccessKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
return &Deployer{
|
||||
config: config,
|
||||
logger: slog.Default(),
|
||||
sdkClient: client,
|
||||
config: config,
|
||||
logger: slog.Default(),
|
||||
sdkClients: clients,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -89,14 +91,14 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
return lo.FromPtr(domainItem.DomainName) == d.config.Domain
|
||||
})
|
||||
if len(domains) == 0 {
|
||||
return nil, errors.New("could not find domain")
|
||||
}
|
||||
|
||||
domainIds = lo.Map(domains, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
domainIds = lo.Map(domains, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
return lo.FromPtr(domainItem.DomainId)
|
||||
})
|
||||
}
|
||||
@@ -112,14 +114,14 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
return nil, err
|
||||
}
|
||||
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
return xcerthostname.IsMatch(d.config.Domain, lo.FromPtr(domainItem.DomainName))
|
||||
})
|
||||
if len(domains) == 0 {
|
||||
return nil, errors.New("could not find any domains matched by wildcard")
|
||||
}
|
||||
|
||||
domainIds = lo.Map(domains, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
domainIds = lo.Map(domains, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
return lo.FromPtr(domainItem.DomainId)
|
||||
})
|
||||
}
|
||||
@@ -131,14 +133,14 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
return nil, err
|
||||
}
|
||||
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
domains := lo.Filter(domainCandidates, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) bool {
|
||||
return xcerthostname.IsMatchByCertificatePEM(certPEM, lo.FromPtr(domainItem.DomainName))
|
||||
})
|
||||
if len(domains) == 0 {
|
||||
return nil, errors.New("could not find any domains matched by certificate")
|
||||
}
|
||||
|
||||
domainIds = lo.Map(domains, func(domainItem *hcaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
domainIds = lo.Map(domains, func(domainItem *hwaadmodelv2.InstanceDomainItem, _ int) string {
|
||||
return lo.FromPtr(domainItem.DomainId)
|
||||
})
|
||||
}
|
||||
@@ -173,8 +175,8 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
|
||||
func (d *Deployer) getAllDomainsByInstanceId(ctx context.Context, cloudInstanceId string) ([]*hcaadmodelv2.InstanceDomainItem, error) {
|
||||
domains := make([]*hcaadmodelv2.InstanceDomainItem, 0)
|
||||
func (d *Deployer) getAllDomainsByInstanceId(ctx context.Context, cloudInstanceId string) ([]*hwaadmodelv2.InstanceDomainItem, error) {
|
||||
domains := make([]*hwaadmodelv2.InstanceDomainItem, 0)
|
||||
|
||||
// 查询实例关联的域名信息
|
||||
// REF: https://support.huaweicloud.com/intl/zh-cn/api-aad/ListInstanceDomains.html
|
||||
@@ -187,12 +189,12 @@ func (d *Deployer) getAllDomainsByInstanceId(ctx context.Context, cloudInstanceI
|
||||
default:
|
||||
}
|
||||
|
||||
listInstanceDomainsReq := &hcaadmodelv2.ListInstanceDomainsRequest{
|
||||
listInstanceDomainsReq := &hwaadmodelv2.ListInstanceDomainsRequest{
|
||||
InstanceId: cloudInstanceId,
|
||||
Offset: lo.ToPtr(int32(listInstanceDomainsOffset)),
|
||||
Limit: lo.ToPtr(int32(listInstanceDomainsLimit)),
|
||||
}
|
||||
listInstanceDomainsResp, err := d.sdkClient.ListInstanceDomains(listInstanceDomainsReq)
|
||||
listInstanceDomainsResp, err := d.sdkClients.AADv2.ListInstanceDomains(listInstanceDomainsReq)
|
||||
d.logger.Debug("sdk request 'aad.ListInstanceDomains'", slog.Any("request", listInstanceDomainsReq), slog.Any("response", listInstanceDomainsResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'aad.ListInstanceDomains': %w", err)
|
||||
@@ -224,8 +226,8 @@ func (d *Deployer) getAllDomainsByInstanceId(ctx context.Context, cloudInstanceI
|
||||
func (d *Deployer) updateDomainCertificate(ctx context.Context, cloudDomainId string, certPEM, privkeyPEM string) error {
|
||||
// 上传域名对应证书
|
||||
// REF: https://support.huaweicloud.com/intl/zh-cn/api-aad/SetCertForDomain.html
|
||||
setCertForDomainReq := &hcaadmodelv1.SetCertForDomainRequest{
|
||||
Body: &hcaadmodelv1.CertificateBody{
|
||||
setCertForDomainReq := &hwaadmodelv1.SetCertForDomainRequest{
|
||||
Body: &hwaadmodelv1.CertificateBody{
|
||||
OpType: 0,
|
||||
DomainId: cloudDomainId,
|
||||
CertName: fmt.Sprintf("certimate_%d", time.Now().UnixMilli()),
|
||||
@@ -233,7 +235,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, cloudDomainId st
|
||||
CertKeyFile: lo.ToPtr(privkeyPEM),
|
||||
},
|
||||
}
|
||||
setCertForDomainResp, err := d.sdkClient.SetCertForDomain(setCertForDomainReq)
|
||||
setCertForDomainResp, err := d.sdkClients.AADv1.SetCertForDomain(setCertForDomainReq)
|
||||
d.logger.Debug("sdk request 'aad.SetCertForDomain'", slog.Any("request", setCertForDomainReq), slog.Any("response", setCertForDomainResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'aad.SetCertForDomain': %w", err)
|
||||
@@ -242,30 +244,64 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, cloudDomainId st
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey string) (*internal.AadClient, error) {
|
||||
region := "cn-north-4" // AAD 服务默认区域:华北北京四
|
||||
func createSDKClients(accessKeyId, secretAccessKey string) (*wSDKClients, error) {
|
||||
wsdk := &wSDKClients{}
|
||||
|
||||
auth, err := global.NewCredentialsBuilder().
|
||||
WithAk(accessKeyId).
|
||||
WithSk(secretAccessKey).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
{
|
||||
region := "cn-north-4" // AAD 服务默认区域:华北北京四
|
||||
|
||||
auth, err := global.NewCredentialsBuilder().
|
||||
WithAk(accessKeyId).
|
||||
WithSk(secretAccessKey).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hwaadregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hwaadv1.AadClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hwaadv1.NewAadClient(hcClient)
|
||||
wsdk.AADv1 = client
|
||||
}
|
||||
|
||||
hcRegion, err := hcaadregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
{
|
||||
region := "cn-north-4" // AAD 服务默认区域:华北北京四
|
||||
|
||||
auth, err := global.NewCredentialsBuilder().
|
||||
WithAk(accessKeyId).
|
||||
WithSk(secretAccessKey).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hwaadregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hwaadv2.AadClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hwaadv2.NewAadClient(hcClient)
|
||||
wsdk.AADv2 = client
|
||||
}
|
||||
|
||||
hcClient, err := hcaad.AadClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewAadClient(hcClient)
|
||||
return client, nil
|
||||
return wsdk, nil
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwaadv1 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1"
|
||||
modelv1 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v1/model"
|
||||
hwaadv2 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v2"
|
||||
modelv2 "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aad/v2/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/aad/v2/aad_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type AadClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewAadClient(hcClient *httpclient.HcHttpClient) *AadClient {
|
||||
return &AadClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *AadClient) ListInstanceDomains(request *modelv2.ListInstanceDomainsRequest) (*modelv2.ListInstanceDomainsResponse, error) {
|
||||
requestDef := hwaadv2.GenReqDefForListInstanceDomains()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*modelv2.ListInstanceDomainsResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AadClient) SetCertForDomain(request *modelv1.SetCertForDomainRequest) (*modelv1.SetCertForDomainResponse, error) {
|
||||
requestDef := hwaadv1.GenReqDefForSetCertForDomain()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*modelv1.SetCertForDomainResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,15 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hcapig "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2"
|
||||
hcapigmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2/model"
|
||||
hcapigregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2/region"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwapigmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2/model"
|
||||
hwapigregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-apig/internal"
|
||||
hwapig "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/apig/v2"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -40,7 +39,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ApigClient
|
||||
sdkClient *hwapig.ApigClient
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
@@ -96,7 +95,7 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 查询证书详情
|
||||
// REF: https://support.huaweicloud.com/api-apig/ShowDetailsOfCertificateV2.html
|
||||
showDetailsOfCertificateV2Req := &hcapigmodel.ShowDetailsOfCertificateV2Request{
|
||||
showDetailsOfCertificateV2Req := &hwapigmodel.ShowDetailsOfCertificateV2Request{
|
||||
CertificateId: d.config.CertificateId,
|
||||
}
|
||||
showDetailsOfCertificateV2Resp, err := d.sdkClient.ShowDetailsOfCertificateV2(showDetailsOfCertificateV2Req)
|
||||
@@ -107,15 +106,15 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 修改 SSL 证书
|
||||
// REF: https://support.huaweicloud.com/api-apig/UpdateCertificateV2.html
|
||||
updateCertificateV2Req := &hcapigmodel.UpdateCertificateV2Request{
|
||||
updateCertificateV2Req := &hwapigmodel.UpdateCertificateV2Request{
|
||||
CertificateId: d.config.CertificateId,
|
||||
Body: &hcapigmodel.CertificateForm{
|
||||
Body: &hwapigmodel.CertificateForm{
|
||||
Name: fmt.Sprintf("certimate_%d", time.Now().UnixMilli()),
|
||||
CertContent: certPEM,
|
||||
PrivateKey: privkeyPEM,
|
||||
Type: lo.
|
||||
If(showDetailsOfCertificateV2Resp.Type.Value() == hcapigmodel.GetCertificateFormTypeEnum().INSTANCE.Value(), lo.ToPtr(hcapigmodel.GetCertificateFormTypeEnum().INSTANCE)).
|
||||
Else(lo.ToPtr(hcapigmodel.GetCertificateFormTypeEnum().GLOBAL)),
|
||||
If(showDetailsOfCertificateV2Resp.Type.Value() == hwapigmodel.GetCertificateFormTypeEnum().INSTANCE.Value(), lo.ToPtr(hwapigmodel.GetCertificateFormTypeEnum().INSTANCE)).
|
||||
Else(lo.ToPtr(hwapigmodel.GetCertificateFormTypeEnum().GLOBAL)),
|
||||
InstanceId: showDetailsOfCertificateV2Resp.InstanceId,
|
||||
},
|
||||
}
|
||||
@@ -128,7 +127,7 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ApigClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwapig.ApigClient, error) {
|
||||
projectId, err := getSDKProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -143,12 +142,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Api
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcapigregion.SafeValueOf(region)
|
||||
hcRegion, err := hwapigregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcapig.ApigClientBuilder().
|
||||
hcClient, err := hwapig.ApigClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -156,7 +155,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Api
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewApigClient(hcClient)
|
||||
client := hwapig.NewApigClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -169,12 +168,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -182,9 +181,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciamModel.KeystoneListProjectsRequest{
|
||||
request := &hwiamModel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -8,15 +8,14 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hccdn "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
|
||||
hccdnmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
|
||||
hccdnregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/region"
|
||||
hwcdnmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
|
||||
hwcdnregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-cdn/internal"
|
||||
hwcdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -39,7 +38,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CdnClient
|
||||
sdkClient *hwcdn.CdnClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
EnterpriseProjectId: config.EnterpriseProjectId,
|
||||
@@ -191,7 +190,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
listDomainsReq := &hccdnmodel.ListDomainsRequest{
|
||||
listDomainsReq := &hwcdnmodel.ListDomainsRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
PageNumber: lo.ToPtr(int32(listDomainsPageNumber)),
|
||||
PageSize: lo.ToPtr(int32(listDomainsPageSize)),
|
||||
@@ -229,10 +228,10 @@ func (d *Deployer) updateDomainsCertificate(ctx context.Context, domains []strin
|
||||
// 更新加速域名配置
|
||||
// REF: https://support.huaweicloud.com/api-cdn/UpdateDomainMultiCertificates.html
|
||||
// REF: https://support.huaweicloud.com/usermanual-cdn/cdn_01_0306.html
|
||||
updateDomainMultiCertificatesReq := &hccdnmodel.UpdateDomainMultiCertificatesRequest{
|
||||
updateDomainMultiCertificatesReq := &hwcdnmodel.UpdateDomainMultiCertificatesRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
Body: &hccdnmodel.UpdateDomainMultiCertificatesRequestBody{
|
||||
Https: &hccdnmodel.UpdateDomainMultiCertificatesRequestBodyContent{
|
||||
Body: &hwcdnmodel.UpdateDomainMultiCertificatesRequestBody{
|
||||
Https: &hwcdnmodel.UpdateDomainMultiCertificatesRequestBodyContent{
|
||||
DomainName: strings.Join(domains, ","),
|
||||
HttpsSwitch: 1,
|
||||
CertificateType: lo.ToPtr(int32(2)),
|
||||
@@ -250,7 +249,7 @@ func (d *Deployer) updateDomainsCertificate(ctx context.Context, domains []strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.CdnClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwcdn.CdnClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-1" // CDN 服务默认区域:华北北京一
|
||||
}
|
||||
@@ -263,12 +262,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Cdn
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hccdnregion.SafeValueOf(region)
|
||||
hcRegion, err := hwcdnregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hccdn.CdnClientBuilder().
|
||||
hcClient, err := hwcdn.CdnClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -276,6 +275,6 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Cdn
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewCdnClient(hcClient)
|
||||
client := hwcdn.NewCdnClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -9,18 +9,17 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hcelb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
hcelbmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
hcelbregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwelbmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
hwelbregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiammodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-elb"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-elb"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-elb/internal"
|
||||
hwelb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -48,7 +47,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ElbClient
|
||||
sdkClient *hwelb.ElbClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
EnterpriseProjectId: config.EnterpriseProjectId,
|
||||
@@ -124,7 +123,7 @@ func (d *Deployer) deployToLoadbalancer(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 查询负载均衡器详情
|
||||
// REF: https://support.huaweicloud.com/api-elb/ShowLoadBalancer.html
|
||||
showLoadBalancerReq := &hcelbmodel.ShowLoadBalancerRequest{
|
||||
showLoadBalancerReq := &hwelbmodel.ShowLoadBalancerRequest{
|
||||
LoadbalancerId: d.config.LoadbalancerId,
|
||||
}
|
||||
showLoadBalancerResp, err := d.sdkClient.ShowLoadBalancer(showLoadBalancerReq)
|
||||
@@ -144,7 +143,7 @@ func (d *Deployer) deployToLoadbalancer(ctx context.Context, certPEM, privkeyPEM
|
||||
default:
|
||||
}
|
||||
|
||||
listListenersReq := &hcelbmodel.ListListenersRequest{
|
||||
listListenersReq := &hwelbmodel.ListListenersRequest{
|
||||
Marker: listListenersMarker,
|
||||
Limit: lo.ToPtr(int32(2000)),
|
||||
Protocol: &[]string{"HTTPS", "TERMINATED_HTTPS"},
|
||||
@@ -248,7 +247,7 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerId string, cloudCertId string) error {
|
||||
// 查询监听器详情
|
||||
// REF: https://support.huaweicloud.com/api-elb/ShowListener.html
|
||||
showListenerReq := &hcelbmodel.ShowListenerRequest{
|
||||
showListenerReq := &hwelbmodel.ShowListenerRequest{
|
||||
ListenerId: cloudListenerId,
|
||||
}
|
||||
showListenerResp, err := d.sdkClient.ShowListener(showListenerReq)
|
||||
@@ -259,10 +258,10 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
|
||||
// 更新监听器
|
||||
// REF: https://support.huaweicloud.com/api-elb/UpdateListener.html
|
||||
updateListenerReq := &hcelbmodel.UpdateListenerRequest{
|
||||
updateListenerReq := &hwelbmodel.UpdateListenerRequest{
|
||||
ListenerId: cloudListenerId,
|
||||
Body: &hcelbmodel.UpdateListenerRequestBody{
|
||||
Listener: &hcelbmodel.UpdateListenerOption{
|
||||
Body: &hwelbmodel.UpdateListenerRequestBody{
|
||||
Listener: &hwelbmodel.UpdateListenerOption{
|
||||
DefaultTlsContainerRef: lo.ToPtr(cloudCertId),
|
||||
},
|
||||
},
|
||||
@@ -273,7 +272,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
sniCertIds := make([]string, 0)
|
||||
sniCertIds = append(sniCertIds, cloudCertId)
|
||||
|
||||
listOldCertificateReq := &hcelbmodel.ListCertificatesRequest{
|
||||
listOldCertificateReq := &hwelbmodel.ListCertificatesRequest{
|
||||
Id: &showListenerResp.Listener.SniContainerRefs,
|
||||
}
|
||||
listOldCertificateResp, err := d.sdkClient.ListCertificates(listOldCertificateReq)
|
||||
@@ -282,7 +281,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
return fmt.Errorf("failed to execute sdk request 'elb.ListCertificates': %w", err)
|
||||
}
|
||||
|
||||
showNewCertificateReq := &hcelbmodel.ShowCertificateRequest{
|
||||
showNewCertificateReq := &hwelbmodel.ShowCertificateRequest{
|
||||
CertificateId: cloudCertId,
|
||||
}
|
||||
showNewCertificateResp, err := d.sdkClient.ShowCertificate(showNewCertificateReq)
|
||||
@@ -323,7 +322,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ElbClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwelb.ElbClient, error) {
|
||||
projectId, err := getSDKProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -338,12 +337,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Elb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcelbregion.SafeValueOf(region)
|
||||
hcRegion, err := hwelbregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcelb.ElbClientBuilder().
|
||||
hcClient, err := hwelb.ElbClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -351,7 +350,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Elb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewElbClient(hcClient)
|
||||
client := hwelb.NewElbClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -368,12 +367,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -381,9 +380,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciammodel.KeystoneListProjectsRequest{
|
||||
request := &hwiammodel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -8,18 +8,17 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hclive "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1"
|
||||
hclivemodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/model"
|
||||
hcliveregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwlivemodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/model"
|
||||
hwliveregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-live/internal"
|
||||
hwlive "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -42,7 +41,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.LiveClient
|
||||
sdkClient *hwlive.LiveClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
EnterpriseProjectId: config.EnterpriseProjectId,
|
||||
@@ -160,7 +159,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
|
||||
// 查询直播域名
|
||||
// REF: https://support.huaweicloud.com/api-live/ShowDomain.html
|
||||
showDomainReq := &hclivemodel.ShowDomainRequest{
|
||||
showDomainReq := &hwlivemodel.ShowDomainRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
}
|
||||
showDomainResp, err := d.sdkClient.ShowDomain(showDomainReq)
|
||||
@@ -184,10 +183,10 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
func (d *Deployer) updateDomainsCertificate(ctx context.Context, domain string, cloudCertId string) error {
|
||||
// 修改指定域名的 HTTPS 证书配置
|
||||
// REF: https://support.huaweicloud.com/api-live/UpdateDomainHttpsCert.html
|
||||
updateDomainHttpsCertReq := &hclivemodel.UpdateDomainHttpsCertRequest{
|
||||
updateDomainHttpsCertReq := &hwlivemodel.UpdateDomainHttpsCertRequest{
|
||||
Domain: domain,
|
||||
Body: &hclivemodel.DomainHttpsCertInfo{
|
||||
TlsCertificate: &hclivemodel.TlsCertificateInfo{
|
||||
Body: &hwlivemodel.DomainHttpsCertInfo{
|
||||
TlsCertificate: &hwlivemodel.TlsCertificateInfo{
|
||||
Source: lo.ToPtr("scm"),
|
||||
CertId: lo.ToPtr(cloudCertId),
|
||||
},
|
||||
@@ -202,7 +201,7 @@ func (d *Deployer) updateDomainsCertificate(ctx context.Context, domain string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.LiveClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwlive.LiveClient, error) {
|
||||
projectId, err := getSDKProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -217,12 +216,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Liv
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcliveregion.SafeValueOf(region)
|
||||
hcRegion, err := hwliveregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hclive.LiveClientBuilder().
|
||||
hcClient, err := hwlive.LiveClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -230,7 +229,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Liv
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewLiveClient(hcClient)
|
||||
client := hwlive.NewLiveClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -243,12 +242,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -256,9 +255,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciamModel.KeystoneListProjectsRequest{
|
||||
request := &hwiamModel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-scm"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
EnterpriseProjectId: config.EnterpriseProjectId,
|
||||
|
||||
@@ -9,18 +9,17 @@ import (
|
||||
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
|
||||
hciam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hciamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hciamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hcwaf "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
hcwafmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
hcwafregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/region"
|
||||
hwiam "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3"
|
||||
hwiamModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/model"
|
||||
hwiamregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/iam/v3/region"
|
||||
hwwafmodel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
hwwafregion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/region"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-waf"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/huaweicloud-waf"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/huaweicloud-waf/internal"
|
||||
hwwaf "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -45,7 +44,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.WafClient
|
||||
sdkClient *hwwaf.WafClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
EnterpriseProjectId: config.EnterpriseProjectId,
|
||||
@@ -129,7 +128,7 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 查询证书
|
||||
// REF: https://support.huaweicloud.com/api-waf/ShowCertificate.html
|
||||
showCertificateReq := &hcwafmodel.ShowCertificateRequest{
|
||||
showCertificateReq := &hwwafmodel.ShowCertificateRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
CertificateId: d.config.CertificateId,
|
||||
}
|
||||
@@ -141,10 +140,10 @@ func (d *Deployer) deployToCertificate(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 更新证书
|
||||
// REF: https://support.huaweicloud.com/api-waf/UpdateCertificate.html
|
||||
updateCertificateReq := &hcwafmodel.UpdateCertificateRequest{
|
||||
updateCertificateReq := &hwwafmodel.UpdateCertificateRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
CertificateId: d.config.CertificateId,
|
||||
Body: &hcwafmodel.UpdateCertificateRequestBody{
|
||||
Body: &hwwafmodel.UpdateCertificateRequestBody{
|
||||
Name: *showCertificateResp.Name,
|
||||
Content: lo.ToPtr(certPEM),
|
||||
Key: lo.ToPtr(privkeyPEM),
|
||||
@@ -184,7 +183,7 @@ func (d *Deployer) deployToCloudServer(ctx context.Context, certPEM, privkeyPEM
|
||||
default:
|
||||
}
|
||||
|
||||
listHostReq := &hcwafmodel.ListHostRequest{
|
||||
listHostReq := &hwwafmodel.ListHostRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
Hostname: lo.ToPtr(strings.TrimPrefix(d.config.Domain, "*")),
|
||||
Page: lo.ToPtr(int32(listHostPage)),
|
||||
@@ -219,10 +218,10 @@ func (d *Deployer) deployToCloudServer(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 更新云模式防护域名的配置
|
||||
// REF: https://support.huaweicloud.com/api-waf/UpdateHost.html
|
||||
updateHostReq := &hcwafmodel.UpdateHostRequest{
|
||||
updateHostReq := &hwwafmodel.UpdateHostRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
InstanceId: hostId,
|
||||
Body: &hcwafmodel.UpdateHostRequestBody{
|
||||
Body: &hwwafmodel.UpdateHostRequestBody{
|
||||
Certificateid: lo.ToPtr(upres.CertId),
|
||||
Certificatename: lo.ToPtr(upres.CertName),
|
||||
},
|
||||
@@ -261,7 +260,7 @@ func (d *Deployer) deployToPremiumHost(ctx context.Context, certPEM, privkeyPEM
|
||||
default:
|
||||
}
|
||||
|
||||
listPremiumHostReq := &hcwafmodel.ListPremiumHostRequest{
|
||||
listPremiumHostReq := &hwwafmodel.ListPremiumHostRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
Hostname: lo.ToPtr(strings.TrimPrefix(d.config.Domain, "*")),
|
||||
Page: lo.ToPtr(fmt.Sprintf("%d", listPremiumHostPage)),
|
||||
@@ -296,10 +295,10 @@ func (d *Deployer) deployToPremiumHost(ctx context.Context, certPEM, privkeyPEM
|
||||
|
||||
// 修改独享模式域名配置
|
||||
// REF: https://support.huaweicloud.com/api-waf/UpdatePremiumHost.html
|
||||
updatePremiumHostReq := &hcwafmodel.UpdatePremiumHostRequest{
|
||||
updatePremiumHostReq := &hwwafmodel.UpdatePremiumHostRequest{
|
||||
EnterpriseProjectId: lo.EmptyableToPtr(d.config.EnterpriseProjectId),
|
||||
HostId: hostId,
|
||||
Body: &hcwafmodel.UpdatePremiumHostRequestBody{
|
||||
Body: &hwwafmodel.UpdatePremiumHostRequestBody{
|
||||
Certificateid: lo.ToPtr(upres.CertId),
|
||||
Certificatename: lo.ToPtr(upres.CertName),
|
||||
},
|
||||
@@ -313,7 +312,7 @@ func (d *Deployer) deployToPremiumHost(ctx context.Context, certPEM, privkeyPEM
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hwwaf.WafClient, error) {
|
||||
projectId, err := getSDKProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -328,12 +327,12 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Waf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcRegion, err := hcwafregion.SafeValueOf(region)
|
||||
hcRegion, err := hwwafregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hcClient, err := hcwaf.WafClientBuilder().
|
||||
hcClient, err := hwwaf.WafClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -341,7 +340,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.Waf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := internal.NewWafClient(hcClient)
|
||||
client := hwwaf.NewWafClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -354,12 +353,12 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcRegion, err := hciamregion.SafeValueOf(region)
|
||||
hcRegion, err := hwiamregion.SafeValueOf(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hcClient, err := hciam.IamClientBuilder().
|
||||
hcClient, err := hwiam.IamClientBuilder().
|
||||
WithRegion(hcRegion).
|
||||
WithCredential(auth).
|
||||
SafeBuild()
|
||||
@@ -367,9 +366,9 @@ func getSDKProjectId(accessKeyId, secretAccessKey, region string) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := hciam.NewIamClient(hcClient)
|
||||
client := hwiam.NewIamClient(hcClient)
|
||||
|
||||
request := &hciamModel.KeystoneListProjectsRequest{
|
||||
request := &hwiamModel.KeystoneListProjectsRequest{
|
||||
Name: ®ion,
|
||||
}
|
||||
response, err := client.KeystoneListProjects(request)
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdcommon "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
|
||||
jdlb "github.com/jdcloud-api/jdcloud-sdk-go/services/lb/apis"
|
||||
jdlbmodel "github.com/jdcloud-api/jdcloud-sdk-go/services/lb/models"
|
||||
jdlbapis "github.com/jdcloud-api/jdcloud-sdk-go/services/lb/apis"
|
||||
jdlbmodels "github.com/jdcloud-api/jdcloud-sdk-go/services/lb/models"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/jdcloud-alb/internal"
|
||||
jdlb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/lb/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -42,7 +42,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.LbClient
|
||||
sdkClient *jdlb.LbClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
})
|
||||
@@ -119,7 +119,7 @@ func (d *Deployer) deployToLoadbalancer(ctx context.Context, cloudCertId string)
|
||||
|
||||
// 查询负载均衡器详情
|
||||
// REF: https://docs.jdcloud.com/cn/load-balancer/api/describeloadbalancer
|
||||
describeLoadBalancerReq := jdlb.NewDescribeLoadBalancerRequestWithoutParam()
|
||||
describeLoadBalancerReq := jdlbapis.NewDescribeLoadBalancerRequestWithoutParam()
|
||||
describeLoadBalancerReq.SetRegionId(d.config.RegionId)
|
||||
describeLoadBalancerReq.SetLoadBalancerId(d.config.LoadbalancerId)
|
||||
describeLoadBalancerResp, err := d.sdkClient.DescribeLoadBalancer(describeLoadBalancerReq)
|
||||
@@ -140,7 +140,7 @@ func (d *Deployer) deployToLoadbalancer(ctx context.Context, cloudCertId string)
|
||||
default:
|
||||
}
|
||||
|
||||
describeListenersReq := jdlb.NewDescribeListenersRequestWithoutParam()
|
||||
describeListenersReq := jdlbapis.NewDescribeListenersRequestWithoutParam()
|
||||
describeListenersReq.SetRegionId(d.config.RegionId)
|
||||
describeListenersReq.SetFilters([]jdcommon.Filter{{Name: "loadBalancerId", Values: []string{d.config.LoadbalancerId}}})
|
||||
describeListenersReq.SetPageSize(describeListenersPageNumber)
|
||||
@@ -207,7 +207,7 @@ func (d *Deployer) deployToListener(ctx context.Context, cloudCertId string) err
|
||||
func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerId string, cloudCertId string) error {
|
||||
// 查询监听器详情
|
||||
// REF: https://docs.jdcloud.com/cn/load-balancer/api/describelistener
|
||||
describeListenerReq := jdlb.NewDescribeListenerRequestWithoutParam()
|
||||
describeListenerReq := jdlbapis.NewDescribeListenerRequestWithoutParam()
|
||||
describeListenerReq.SetRegionId(d.config.RegionId)
|
||||
describeListenerReq.SetListenerId(cloudListenerId)
|
||||
describeListenerResp, err := d.sdkClient.DescribeListener(describeListenerReq)
|
||||
@@ -221,10 +221,10 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
|
||||
// 修改监听器信息
|
||||
// REF: https://docs.jdcloud.com/cn/load-balancer/api/updatelistener
|
||||
updateListenerReq := jdlb.NewUpdateListenerRequestWithoutParam()
|
||||
updateListenerReq := jdlbapis.NewUpdateListenerRequestWithoutParam()
|
||||
updateListenerReq.SetRegionId(d.config.RegionId)
|
||||
updateListenerReq.SetListenerId(cloudListenerId)
|
||||
updateListenerReq.SetCertificateSpecs([]jdlbmodel.CertificateSpec{{CertificateId: cloudCertId}})
|
||||
updateListenerReq.SetCertificateSpecs([]jdlbmodels.CertificateSpec{{CertificateId: cloudCertId}})
|
||||
updateListenerResp, err := d.sdkClient.UpdateListener(updateListenerReq)
|
||||
d.logger.Debug("sdk request 'lb.UpdateListener'", slog.Any("request", updateListenerReq), slog.Any("response", updateListenerResp))
|
||||
if err != nil {
|
||||
@@ -233,7 +233,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
} else {
|
||||
// 指定 SNI,需部署到扩展证书
|
||||
|
||||
extCertSpecs := lo.Filter(describeListenerResp.Result.Listener.ExtensionCertificateSpecs, func(extCertSpec jdlbmodel.ExtensionCertificateSpec, _ int) bool {
|
||||
extCertSpecs := lo.Filter(describeListenerResp.Result.Listener.ExtensionCertificateSpecs, func(extCertSpec jdlbmodels.ExtensionCertificateSpec, _ int) bool {
|
||||
return extCertSpec.Domain == d.config.Domain
|
||||
})
|
||||
if len(extCertSpecs) == 0 {
|
||||
@@ -242,11 +242,11 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
|
||||
// 批量修改扩展证书
|
||||
// REF: https://docs.jdcloud.com/cn/load-balancer/api/updatelistenercertificates
|
||||
updateListenerCertificatesReq := jdlb.NewUpdateListenerCertificatesRequestWithoutParam()
|
||||
updateListenerCertificatesReq := jdlbapis.NewUpdateListenerCertificatesRequestWithoutParam()
|
||||
updateListenerCertificatesReq.SetRegionId(d.config.RegionId)
|
||||
updateListenerCertificatesReq.SetListenerId(cloudListenerId)
|
||||
updateListenerCertificatesReq.SetCertificates(lo.Map(extCertSpecs, func(extCertSpec jdlbmodel.ExtensionCertificateSpec, _ int) jdlbmodel.ExtCertificateUpdateSpec {
|
||||
return jdlbmodel.ExtCertificateUpdateSpec{
|
||||
updateListenerCertificatesReq.SetCertificates(lo.Map(extCertSpecs, func(extCertSpec jdlbmodels.ExtensionCertificateSpec, _ int) jdlbmodels.ExtCertificateUpdateSpec {
|
||||
return jdlbmodels.ExtCertificateUpdateSpec{
|
||||
CertificateBindId: extCertSpec.CertificateBindId,
|
||||
CertificateId: &cloudCertId,
|
||||
Domain: &extCertSpec.Domain,
|
||||
@@ -262,8 +262,9 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudListenerI
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.LbClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdlb.LbClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := internal.NewLbClient(clientCredentials)
|
||||
client := jdlb.NewLbClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import (
|
||||
"strings"
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdcdn "github.com/jdcloud-api/jdcloud-sdk-go/services/cdn/apis"
|
||||
jdcdnapis "github.com/jdcloud-api/jdcloud-sdk-go/services/cdn/apis"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/jdcloud-cdn/internal"
|
||||
jdcdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/cdn/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CdnClient
|
||||
sdkClient *jdcdn.CdnClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
})
|
||||
@@ -178,7 +178,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
getDomainListReq := jdcdn.NewGetDomainListRequestWithoutParam()
|
||||
getDomainListReq := jdcdnapis.NewGetDomainListRequestWithoutParam()
|
||||
getDomainListReq.SetPageNumber(getDomainListPageNumber)
|
||||
getDomainListReq.SetPageSize(getDomainListPageSize)
|
||||
getDomainListResp, err := d.sdkClient.GetDomainList(getDomainListReq)
|
||||
@@ -209,7 +209,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, cloudCertId string) error {
|
||||
// 查询域名配置信息
|
||||
// REF: https://docs.jdcloud.com/cn/cdn/api/querydomainconfig
|
||||
queryDomainConfigReq := jdcdn.NewQueryDomainConfigRequestWithoutParam()
|
||||
queryDomainConfigReq := jdcdnapis.NewQueryDomainConfigRequestWithoutParam()
|
||||
queryDomainConfigReq.SetDomain(domain)
|
||||
queryDomainConfigResp, err := d.sdkClient.QueryDomainConfig(queryDomainConfigReq)
|
||||
d.logger.Debug("sdk request 'cdn.QueryDomainConfig'", slog.Any("request", queryDomainConfigReq), slog.Any("response", queryDomainConfigResp))
|
||||
@@ -219,7 +219,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
|
||||
// 设置通讯协议
|
||||
// REF: https://docs.jdcloud.com/cn/cdn/api/sethttptype
|
||||
setHttpTypeReq := jdcdn.NewSetHttpTypeRequestWithoutParam()
|
||||
setHttpTypeReq := jdcdnapis.NewSetHttpTypeRequestWithoutParam()
|
||||
setHttpTypeReq.SetDomain(domain)
|
||||
setHttpTypeReq.SetHttpType("https")
|
||||
setHttpTypeReq.SetCertFrom("ssl")
|
||||
@@ -234,8 +234,9 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.CdnClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdcdn.CdnClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := internal.NewCdnClient(clientCredentials)
|
||||
client := jdcdn.NewCdnClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"log/slog"
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdlive "github.com/jdcloud-api/jdcloud-sdk-go/services/live/apis"
|
||||
jdliveapis "github.com/jdcloud-api/jdcloud-sdk-go/services/live/apis"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/jdcloud-live/internal"
|
||||
jdlive "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/live/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.LiveClient
|
||||
sdkClient *jdlive.LiveClient
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
@@ -132,7 +132,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
describeLiveDomainsReq := jdlive.NewDescribeLiveDomainsRequestWithoutParam()
|
||||
describeLiveDomainsReq := jdliveapis.NewDescribeLiveDomainsRequestWithoutParam()
|
||||
describeLiveDomainsReq.SetPageNum(describeLiveDomainsPageNumber)
|
||||
describeLiveDomainsReq.SetPageSize(describeLiveDomainsPageSize)
|
||||
describeLiveDomainsResp, err := d.sdkClient.DescribeLiveDomains(describeLiveDomainsReq)
|
||||
@@ -165,7 +165,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, certPEM, privkeyPEM string) error {
|
||||
// 设置直播证书
|
||||
// REF: https://docs.jdcloud.com/cn/live-video/api/setlivedomaincertificate
|
||||
setLiveDomainCertificateReq := jdlive.NewSetLiveDomainCertificateRequestWithoutParam()
|
||||
setLiveDomainCertificateReq := jdliveapis.NewSetLiveDomainCertificateRequestWithoutParam()
|
||||
setLiveDomainCertificateReq.SetPlayDomain(domain)
|
||||
setLiveDomainCertificateReq.SetCertStatus("on")
|
||||
setLiveDomainCertificateReq.SetCert(certPEM)
|
||||
@@ -179,8 +179,9 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.LiveClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdlive.LiveClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := internal.NewLiveClient(clientCredentials)
|
||||
client := jdlive.NewLiveClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
})
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"time"
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdvod "github.com/jdcloud-api/jdcloud-sdk-go/services/vod/apis"
|
||||
jdvodapis "github.com/jdcloud-api/jdcloud-sdk-go/services/vod/apis"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/jdcloud-vod/internal"
|
||||
jdvod "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/vod/client"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.VodClient
|
||||
sdkClient *jdvod.VodClient
|
||||
}
|
||||
|
||||
var _ deployer.Provider = (*Deployer)(nil)
|
||||
@@ -134,7 +134,7 @@ func (d *Deployer) getAllDomains(ctx context.Context) ([]string, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
listDomainsReq := jdvod.NewListDomainsRequestWithoutParam()
|
||||
listDomainsReq := jdvodapis.NewListDomainsRequestWithoutParam()
|
||||
listDomainsReq.SetPageNumber(listDomainsPageNumber)
|
||||
listDomainsReq.SetPageSize(listDomainsPageSize)
|
||||
listDomainsResp, err := d.sdkClient.ListDomains(listDomainsReq)
|
||||
@@ -171,7 +171,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
|
||||
// 查询域名 SSL 配置
|
||||
// REF: https://docs.jdcloud.com/cn/video-on-demand/api/gethttpssl
|
||||
getHttpSslReq := jdvod.NewGetHttpSslRequestWithoutParam()
|
||||
getHttpSslReq := jdvodapis.NewGetHttpSslRequestWithoutParam()
|
||||
getHttpSslReq.SetDomainId(domainId)
|
||||
getHttpSslResp, err := d.sdkClient.GetHttpSsl(getHttpSslReq)
|
||||
d.logger.Debug("sdk request 'vod.GetHttpSsl'", slog.Any("request", getHttpSslReq), slog.Any("response", getHttpSslResp))
|
||||
@@ -181,7 +181,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
|
||||
// 设置域名 SSL 配置
|
||||
// REF: https://docs.jdcloud.com/cn/video-on-demand/api/sethttpssl
|
||||
setHttpSslReq := jdvod.NewSetHttpSslRequestWithoutParam()
|
||||
setHttpSslReq := jdvodapis.NewSetHttpSslRequestWithoutParam()
|
||||
setHttpSslReq.SetDomainId(domainId)
|
||||
setHttpSslReq.SetTitle(fmt.Sprintf("certimate-%d", time.Now().UnixMilli()))
|
||||
setHttpSslReq.SetSslCert(certPEM)
|
||||
@@ -210,7 +210,7 @@ func (d *Deployer) findDomainIdByDomain(ctx context.Context, domain string) (int
|
||||
default:
|
||||
}
|
||||
|
||||
listDomainsReq := jdvod.NewListDomainsRequestWithoutParam()
|
||||
listDomainsReq := jdvodapis.NewListDomainsRequestWithoutParam()
|
||||
listDomainsReq.SetPageNumber(listDomainsPageNumber)
|
||||
listDomainsReq.SetPageSize(listDomainsPageSize)
|
||||
listDomainsResp, err := d.sdkClient.ListDomains(listDomainsReq)
|
||||
@@ -236,8 +236,9 @@ func (d *Deployer) findDomainIdByDomain(ctx context.Context, domain string) (int
|
||||
return 0, fmt.Errorf("could not find domain '%s'", domain)
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.VodClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdvod.VodClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := internal.NewVodClient(clientCredentials)
|
||||
client := jdvod.NewVodClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"log/slog"
|
||||
|
||||
jdcore "github.com/jdcloud-api/jdcloud-sdk-go/core"
|
||||
jdwaf "github.com/jdcloud-api/jdcloud-sdk-go/services/waf/apis"
|
||||
jdwafmodel "github.com/jdcloud-api/jdcloud-sdk-go/services/waf/models"
|
||||
jdwafapis "github.com/jdcloud-api/jdcloud-sdk-go/services/waf/apis"
|
||||
jdwafmodels "github.com/jdcloud-api/jdcloud-sdk-go/services/waf/models"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/jdcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/jdcloud-waf/internal"
|
||||
jdwaf "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/jdcloud-api/jdcloud-sdk-go/services/waf/client"
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
@@ -32,7 +32,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.WafClient
|
||||
sdkClient *jdwaf.WafClient
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
})
|
||||
@@ -85,10 +85,10 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
|
||||
// 绑定证书
|
||||
// REF: https://docs.jdcloud.com/cn/web-application-firewall/api/bindcert
|
||||
bindCertReq := jdwaf.NewBindCertRequestWithoutParam()
|
||||
bindCertReq := jdwafapis.NewBindCertRequestWithoutParam()
|
||||
bindCertReq.SetRegionId(d.config.RegionId)
|
||||
bindCertReq.SetWafInstanceId(d.config.InstanceId)
|
||||
bindCertReq.SetReq(&jdwafmodel.AssignCertReq{
|
||||
bindCertReq.SetReq(&jdwafmodels.AssignCertReq{
|
||||
WafInstanceId: d.config.InstanceId,
|
||||
Domain: d.config.Domain,
|
||||
CertId: upres.CertId,
|
||||
@@ -102,8 +102,9 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
|
||||
return &deployer.DeployResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*internal.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, accessKeySecret string) (*jdwaf.WafClient, error) {
|
||||
clientCredentials := jdcore.NewCredentials(accessKeyId, accessKeySecret)
|
||||
client := internal.NewWafClient(clientCredentials)
|
||||
client := jdwaf.NewWafClient(clientCredentials)
|
||||
client.DisableLogger()
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/nginxproxymanager"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/nginxproxymanager"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
npmsdk "github.com/certimate-go/certimate/pkg/sdk3rd/nginxproxymanager"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
@@ -69,7 +69,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ServerUrl: config.ServerUrl,
|
||||
AuthMethod: config.AuthMethod,
|
||||
Username: config.Username,
|
||||
@@ -200,9 +200,8 @@ func (d *Deployer) deployToHost(ctx context.Context, certPEM, privkeyPEM string)
|
||||
default:
|
||||
if err := d.updateHostCertificate(ctx, d.config.HostType, hostId, certId); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if i < len(hostIds)-1 {
|
||||
xwait.DelayWithContext(ctx, time.Second*5)
|
||||
} else if i < len(hostIds)-1 {
|
||||
xwait.DelayWithContext(ctx, 5*time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
qiniusdk "github.com/certimate-go/certimate/pkg/sdk3rd/qiniu"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
@@ -45,7 +45,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
|
||||
client := qiniusdk.NewCdnManager(auth.New(config.AccessKey, config.SecretKey))
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/qiniu/go-sdk/v7/auth"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
qiniusdk "github.com/certimate-go/certimate/pkg/sdk3rd/qiniu"
|
||||
)
|
||||
@@ -41,7 +41,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
|
||||
client := qiniusdk.NewKodoManager(auth.New(config.AccessKey, config.SecretKey))
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/qiniu-sslcert"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
@@ -45,7 +45,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
|
||||
manager := pili.NewManager(pili.ManagerConfig{AccessKey: config.AccessKey, SecretKey: config.SecretKey})
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/rainyun-sslcenter"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/rainyun-sslcenter"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
rainyunsdk "github.com/certimate-go/certimate/pkg/sdk3rd/rainyun"
|
||||
)
|
||||
@@ -44,7 +44,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ApiKey: config.ApiKey,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/rainyun-sslcenter"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/rainyun-sslcenter"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, errors.New("the configuration of the deployer provider is nil")
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
ApiKey: config.ApiKey,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package s3_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
provider "github.com/certimate-go/certimate/pkg/core/deployer/providers/s3"
|
||||
)
|
||||
|
||||
var (
|
||||
fInputCertPath string
|
||||
fInputKeyPath string
|
||||
fSshHost string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
fRegion string
|
||||
fBucket string
|
||||
fOutputCertPath string
|
||||
fOutputKeyPath string
|
||||
)
|
||||
|
||||
func init() {
|
||||
argsPrefix := "S3_"
|
||||
|
||||
flag.StringVar(&fInputCertPath, argsPrefix+"INPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fInputKeyPath, argsPrefix+"INPUTKEYPATH", "", "")
|
||||
flag.StringVar(&fSshHost, argsPrefix+"ENDPOINT", "", "")
|
||||
flag.StringVar(&fAccessKey, argsPrefix+"ACCESSKEY", "", "")
|
||||
flag.StringVar(&fSecretKey, argsPrefix+"SECRETKEY", "", "")
|
||||
flag.StringVar(&fRegion, argsPrefix+"REGION", "", "")
|
||||
flag.StringVar(&fBucket, argsPrefix+"BUCKET", "", "")
|
||||
flag.StringVar(&fOutputCertPath, argsPrefix+"OUTPUTCERTPATH", "", "")
|
||||
flag.StringVar(&fOutputKeyPath, argsPrefix+"OUTPUTKEYPATH", "", "")
|
||||
}
|
||||
|
||||
/*
|
||||
Shell command to run this test:
|
||||
|
||||
go test -v ./s3_test.go -args \
|
||||
--S3_INPUTCERTPATH="/path/to/your-input-cert.pem" \
|
||||
--S3_INPUTKEYPATH="/path/to/your-input-key.pem" \
|
||||
--S3_ENDPOINT="http://endpoint" \
|
||||
--S3_ACCESSKEY="your-access-key" \
|
||||
--S3_SECRETKEY="your-secret-key" \
|
||||
--S3_REGION="your-region" \
|
||||
--S3_BUCKET="your-bucket" \
|
||||
--S3_OUTPUTCERTPATH="/path/to/your-output-cert.pem" \
|
||||
--S3_OUTPUTKEYPATH="/path/to/your-output-key.pem"
|
||||
*/
|
||||
func TestDeploy(t *testing.T) {
|
||||
flag.Parse()
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
t.Log(strings.Join([]string{
|
||||
"args:",
|
||||
fmt.Sprintf("INPUTCERTPATH: %v", fInputCertPath),
|
||||
fmt.Sprintf("INPUTKEYPATH: %v", fInputKeyPath),
|
||||
fmt.Sprintf("ENDPOINT: %v", fSshHost),
|
||||
fmt.Sprintf("ACCESSKEY: %v", fAccessKey),
|
||||
fmt.Sprintf("SECRETKEY: %v", fSecretKey),
|
||||
fmt.Sprintf("REGION: %v", fRegion),
|
||||
fmt.Sprintf("BUCKET: %v", fBucket),
|
||||
fmt.Sprintf("OUTPUTCERTPATH: %v", fOutputCertPath),
|
||||
fmt.Sprintf("OUTPUTKEYPATH: %v", fOutputKeyPath),
|
||||
}, "\n"))
|
||||
|
||||
provider, err := provider.NewDeployer(&provider.DeployerConfig{
|
||||
Endpoint: fSshHost,
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
Region: fRegion,
|
||||
Bucket: fBucket,
|
||||
OutputFormat: provider.OUTPUT_FORMAT_PEM,
|
||||
OutputCertObjectKey: fOutputCertPath,
|
||||
OutputKeyObjectKey: fOutputKeyPath,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
}
|
||||
|
||||
fInputCertData, _ := os.ReadFile(fInputCertPath)
|
||||
fInputKeyData, _ := os.ReadFile(fInputKeyPath)
|
||||
res, err := provider.Deploy(context.Background(), string(fInputCertData), string(fInputKeyData))
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
}
|
||||
|
||||
t.Logf("ok: %v", res)
|
||||
})
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
tccdn "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn/v20180606"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/TencentCloud/tencentcloud-sdk-go/blob/master/tencentcloud/cdn/v20180606/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CdnClient struct {
|
||||
common.Client
|
||||
}
|
||||
|
||||
func NewCdnClient(credential common.CredentialIface, region string, clientProfile *profile.ClientProfile) (client *CdnClient, err error) {
|
||||
client = &CdnClient{}
|
||||
client.Init(region).
|
||||
WithCredential(credential).
|
||||
WithProfile(clientProfile)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeCertDomains(request *tccdn.DescribeCertDomainsRequest) (response *tccdn.DescribeCertDomainsResponse, err error) {
|
||||
return c.DescribeCertDomainsWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeCertDomainsWithContext(ctx context.Context, request *tccdn.DescribeCertDomainsRequest) (response *tccdn.DescribeCertDomainsResponse, err error) {
|
||||
if request == nil {
|
||||
request = tccdn.NewDescribeCertDomainsRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "cdn", tccdn.APIVersion, "DescribeCertDomains")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("DescribeCertDomains require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tccdn.NewDescribeCertDomainsResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeDomains(request *tccdn.DescribeDomainsRequest) (response *tccdn.DescribeDomainsResponse, err error) {
|
||||
return c.DescribeDomainsWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeDomainsWithContext(ctx context.Context, request *tccdn.DescribeDomainsRequest) (response *tccdn.DescribeDomainsResponse, err error) {
|
||||
if request == nil {
|
||||
request = tccdn.NewDescribeDomainsRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "cdn", tccdn.APIVersion, "DescribeDomains")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("DescribeDomains require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tccdn.NewDescribeDomainsResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeDomainsConfig(request *tccdn.DescribeDomainsConfigRequest) (response *tccdn.DescribeDomainsConfigResponse, err error) {
|
||||
return c.DescribeDomainsConfigWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *CdnClient) DescribeDomainsConfigWithContext(ctx context.Context, request *tccdn.DescribeDomainsConfigRequest) (response *tccdn.DescribeDomainsConfigResponse, err error) {
|
||||
if request == nil {
|
||||
request = tccdn.NewDescribeDomainsConfigRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "cdn", tccdn.APIVersion, "DescribeDomainsConfig")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("DescribeDomainsConfig require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tccdn.NewDescribeDomainsConfigResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CdnClient) UpdateDomainConfig(request *tccdn.UpdateDomainConfigRequest) (response *tccdn.UpdateDomainConfigResponse, err error) {
|
||||
return c.UpdateDomainConfigWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *CdnClient) UpdateDomainConfigWithContext(ctx context.Context, request *tccdn.UpdateDomainConfigRequest) (response *tccdn.UpdateDomainConfigResponse, err error) {
|
||||
if request == nil {
|
||||
request = tccdn.NewUpdateDomainConfigRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "cdn", tccdn.APIVersion, "UpdateDomainConfig")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("UpdateDomainConfig require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tccdn.NewUpdateDomainConfigResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
@@ -8,14 +8,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/samber/lo"
|
||||
tccdn "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn/v20180606"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/tencentcloud-cdn/internal"
|
||||
tccdn "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn/v20180606"
|
||||
xcerthostname "github.com/certimate-go/certimate/pkg/utils/cert/hostname"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.CdnClient
|
||||
sdkClient *tccdn.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
SecretId: config.SecretId,
|
||||
SecretKey: config.SecretKey,
|
||||
Endpoint: lo.
|
||||
@@ -184,7 +183,7 @@ func (d *Deployer) getMatchedDomainsByWildcard(ctx context.Context, wildcardDoma
|
||||
}
|
||||
describeDomainsReq.Offset = common.Int64Ptr(int64(describeDomainsOffset))
|
||||
describeDomainsReq.Limit = common.Int64Ptr(int64(describeDomainsLimit))
|
||||
describeDomainsResp, err := d.sdkClient.DescribeDomains(describeDomainsReq)
|
||||
describeDomainsResp, err := d.sdkClient.DescribeDomainsWithContext(ctx, describeDomainsReq)
|
||||
d.logger.Debug("sdk request 'cdn.DescribeDomains'", slog.Any("request", describeDomainsReq), slog.Any("response", describeDomainsResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'cdn.DescribeDomains': %w", err)
|
||||
@@ -216,7 +215,7 @@ func (d *Deployer) getMatchedDomainsByCertId(ctx context.Context, cloudCertId st
|
||||
describeCertDomainsReq := tccdn.NewDescribeCertDomainsRequest()
|
||||
describeCertDomainsReq.CertId = common.StringPtr(cloudCertId)
|
||||
describeCertDomainsReq.Product = common.StringPtr("cdn")
|
||||
describeCertDomainsResp, err := d.sdkClient.DescribeCertDomains(describeCertDomainsReq)
|
||||
describeCertDomainsResp, err := d.sdkClient.DescribeCertDomainsWithContext(ctx, describeCertDomainsReq)
|
||||
d.logger.Debug("sdk request 'cdn.DescribeCertDomains'", slog.Any("request", describeCertDomainsReq), slog.Any("response", describeCertDomainsResp))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'cdn.DescribeCertDomains': %w", err)
|
||||
@@ -244,7 +243,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
}
|
||||
describeDomainsConfigReq.Offset = common.Int64Ptr(0)
|
||||
describeDomainsConfigReq.Limit = common.Int64Ptr(1)
|
||||
describeDomainsConfigResp, err := d.sdkClient.DescribeDomainsConfig(describeDomainsConfigReq)
|
||||
describeDomainsConfigResp, err := d.sdkClient.DescribeDomainsConfigWithContext(ctx, describeDomainsConfigReq)
|
||||
d.logger.Debug("sdk request 'cdn.DescribeDomainsConfig'", slog.Any("request", describeDomainsConfigReq), slog.Any("response", describeDomainsConfigResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'cdn.DescribeDomainsConfig': %w", err)
|
||||
@@ -274,7 +273,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
updateDomainConfigReq.Https.CertInfo = &tccdn.ServerCert{
|
||||
CertId: common.StringPtr(cloudCertId),
|
||||
}
|
||||
updateDomainConfigResp, err := d.sdkClient.UpdateDomainConfig(updateDomainConfigReq)
|
||||
updateDomainConfigResp, err := d.sdkClient.UpdateDomainConfigWithContext(ctx, updateDomainConfigReq)
|
||||
d.logger.Debug("sdk request 'cdn.UpdateDomainConfig'", slog.Any("request", updateDomainConfigReq), slog.Any("response", updateDomainConfigResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'cdn.UpdateDomainConfig': %w", err)
|
||||
@@ -283,7 +282,7 @@ func (d *Deployer) updateDomainCertificate(ctx context.Context, domain string, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(secretId, secretKey, endpoint string) (*internal.CdnClient, error) {
|
||||
func createSDKClient(secretId, secretKey, endpoint string) (*tccdn.Client, error) {
|
||||
credential := common.NewCredential(secretId, secretKey)
|
||||
|
||||
cpf := profile.NewClientProfile()
|
||||
@@ -291,7 +290,7 @@ func createSDKClient(secretId, secretKey, endpoint string) (*internal.CdnClient,
|
||||
cpf.HttpProfile.Endpoint = endpoint
|
||||
}
|
||||
|
||||
client, err := internal.NewCdnClient(credential, "", cpf)
|
||||
client, err := tccdn.NewClient(credential, "", cpf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
tcclb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/TencentCloud/tencentcloud-sdk-go/blob/master/tencentcloud/clb/v20180317/client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ClbClient struct {
|
||||
common.Client
|
||||
}
|
||||
|
||||
func NewClbClient(credential common.CredentialIface, region string, clientProfile *profile.ClientProfile) (client *ClbClient, err error) {
|
||||
client = &ClbClient{}
|
||||
client.Init(region).
|
||||
WithCredential(credential).
|
||||
WithProfile(clientProfile)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ClbClient) DescribeListeners(request *tcclb.DescribeListenersRequest) (response *tcclb.DescribeListenersResponse, err error) {
|
||||
return c.DescribeListenersWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *ClbClient) DescribeListenersWithContext(ctx context.Context, request *tcclb.DescribeListenersRequest) (response *tcclb.DescribeListenersResponse, err error) {
|
||||
if request == nil {
|
||||
request = tcclb.NewDescribeListenersRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "clb", tcclb.APIVersion, "DescribeListeners")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("DescribeListeners require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tcclb.NewDescribeListenersResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ClbClient) DescribeTaskStatus(request *tcclb.DescribeTaskStatusRequest) (response *tcclb.DescribeTaskStatusResponse, err error) {
|
||||
return c.DescribeTaskStatusWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *ClbClient) DescribeTaskStatusWithContext(ctx context.Context, request *tcclb.DescribeTaskStatusRequest) (response *tcclb.DescribeTaskStatusResponse, err error) {
|
||||
if request == nil {
|
||||
request = tcclb.NewDescribeTaskStatusRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "clb", tcclb.APIVersion, "DescribeTaskStatus")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("DescribeTaskStatus require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tcclb.NewDescribeTaskStatusResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ClbClient) ModifyDomainAttributes(request *tcclb.ModifyDomainAttributesRequest) (response *tcclb.ModifyDomainAttributesResponse, err error) {
|
||||
return c.ModifyDomainAttributesWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *ClbClient) ModifyDomainAttributesWithContext(ctx context.Context, request *tcclb.ModifyDomainAttributesRequest) (response *tcclb.ModifyDomainAttributesResponse, err error) {
|
||||
if request == nil {
|
||||
request = tcclb.NewModifyDomainAttributesRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "clb", tcclb.APIVersion, "ModifyDomainAttributes")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("ModifyDomainAttributes require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tcclb.NewModifyDomainAttributesResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ClbClient) ModifyListener(request *tcclb.ModifyListenerRequest) (response *tcclb.ModifyListenerResponse, err error) {
|
||||
return c.ModifyListenerWithContext(context.Background(), request)
|
||||
}
|
||||
|
||||
func (c *ClbClient) ModifyListenerWithContext(ctx context.Context, request *tcclb.ModifyListenerRequest) (response *tcclb.ModifyListenerResponse, err error) {
|
||||
if request == nil {
|
||||
request = tcclb.NewModifyListenerRequest()
|
||||
}
|
||||
c.InitBaseRequest(&request.BaseRequest, "clb", tcclb.APIVersion, "ModifyListener")
|
||||
|
||||
if c.GetCredential() == nil {
|
||||
return nil, errors.New("ModifyListener require credential")
|
||||
}
|
||||
|
||||
request.SetContext(ctx)
|
||||
response = tcclb.NewModifyListenerResponse()
|
||||
err = c.Send(request, response)
|
||||
return
|
||||
}
|
||||
@@ -9,14 +9,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/samber/lo"
|
||||
tcclb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core/certmgr"
|
||||
mcertmgr "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl"
|
||||
certmgrimpl "github.com/certimate-go/certimate/pkg/core/certmgr/providers/tencentcloud-ssl"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer"
|
||||
"github.com/certimate-go/certimate/pkg/core/deployer/providers/tencentcloud-clb/internal"
|
||||
tcclb "github.com/certimate-go/certimate/pkg/sdk3rd-trimmed/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317"
|
||||
xwait "github.com/certimate-go/certimate/pkg/utils/wait"
|
||||
)
|
||||
|
||||
@@ -45,7 +44,7 @@ type DeployerConfig struct {
|
||||
type Deployer struct {
|
||||
config *DeployerConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *internal.ClbClient
|
||||
sdkClient *tcclb.Client
|
||||
sdkCertmgr certmgr.Provider
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
|
||||
pcertmgr, err := mcertmgr.NewCertmgr(&mcertmgr.CertmgrConfig{
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
SecretId: config.SecretId,
|
||||
SecretKey: config.SecretKey,
|
||||
Endpoint: lo.
|
||||
@@ -133,7 +132,7 @@ func (d *Deployer) deployToLoadbalancer(ctx context.Context, cloudCertId string)
|
||||
listenerIds := make([]string, 0)
|
||||
describeListenersReq := tcclb.NewDescribeListenersRequest()
|
||||
describeListenersReq.LoadBalancerId = common.StringPtr(d.config.LoadbalancerId)
|
||||
describeListenersResp, err := d.sdkClient.DescribeListeners(describeListenersReq)
|
||||
describeListenersResp, err := d.sdkClient.DescribeListenersWithContext(ctx, describeListenersReq)
|
||||
d.logger.Debug("sdk request 'clb.DescribeListeners'", slog.Any("request", describeListenersReq), slog.Any("response", describeListenersResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'clb.DescribeListeners': %w", err)
|
||||
@@ -212,7 +211,7 @@ func (d *Deployer) deployToRuleDomain(ctx context.Context, cloudCertId string) e
|
||||
SSLMode: common.StringPtr("UNIDIRECTIONAL"),
|
||||
CertId: common.StringPtr(cloudCertId),
|
||||
}
|
||||
modifyDomainAttributesResp, err := d.sdkClient.ModifyDomainAttributes(modifyDomainAttributesReq)
|
||||
modifyDomainAttributesResp, err := d.sdkClient.ModifyDomainAttributesWithContext(ctx, modifyDomainAttributesReq)
|
||||
d.logger.Debug("sdk request 'clb.ModifyDomainAttributes'", slog.Any("request", modifyDomainAttributesReq), slog.Any("response", modifyDomainAttributesResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'clb.ModifyDomainAttributes': %w", err)
|
||||
@@ -223,7 +222,7 @@ func (d *Deployer) deployToRuleDomain(ctx context.Context, cloudCertId string) e
|
||||
if _, err := xwait.UntilWithContext(ctx, func(_ context.Context, _ int) (bool, error) {
|
||||
describeTaskStatusReq := tcclb.NewDescribeTaskStatusRequest()
|
||||
describeTaskStatusReq.TaskId = modifyDomainAttributesResp.Response.RequestId
|
||||
describeTaskStatusResp, err := d.sdkClient.DescribeTaskStatus(describeTaskStatusReq)
|
||||
describeTaskStatusResp, err := d.sdkClient.DescribeTaskStatusWithContext(ctx, describeTaskStatusReq)
|
||||
d.logger.Debug("sdk request 'clb.DescribeTaskStatus'", slog.Any("request", describeTaskStatusReq), slog.Any("response", describeTaskStatusResp))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to execute sdk request 'clb.DescribeTaskStatus': %w", err)
|
||||
@@ -238,7 +237,7 @@ func (d *Deployer) deployToRuleDomain(ctx context.Context, cloudCertId string) e
|
||||
|
||||
d.logger.Info("waiting for tencentcloud task completion ...")
|
||||
return false, nil
|
||||
}, time.Second*5); err != nil {
|
||||
}, 10*time.Second); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -251,7 +250,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan
|
||||
describeListenersReq := tcclb.NewDescribeListenersRequest()
|
||||
describeListenersReq.LoadBalancerId = common.StringPtr(cloudLoadbalancerId)
|
||||
describeListenersReq.ListenerIds = common.StringPtrs([]string{cloudListenerId})
|
||||
describeListenersResp, err := d.sdkClient.DescribeListeners(describeListenersReq)
|
||||
describeListenersResp, err := d.sdkClient.DescribeListenersWithContext(ctx, describeListenersReq)
|
||||
d.logger.Debug("sdk request 'clb.DescribeListeners'", slog.Any("request", describeListenersReq), slog.Any("response", describeListenersResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'clb.DescribeListeners': %w", err)
|
||||
@@ -271,7 +270,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan
|
||||
} else {
|
||||
modifyListenerReq.Certificate.SSLMode = common.StringPtr("UNIDIRECTIONAL")
|
||||
}
|
||||
modifyListenerResp, err := d.sdkClient.ModifyListener(modifyListenerReq)
|
||||
modifyListenerResp, err := d.sdkClient.ModifyListenerWithContext(ctx, modifyListenerReq)
|
||||
d.logger.Debug("sdk request 'clb.ModifyListener'", slog.Any("request", modifyListenerReq), slog.Any("response", modifyListenerResp))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute sdk request 'clb.ModifyListener': %w", err)
|
||||
@@ -282,7 +281,7 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan
|
||||
if _, err := xwait.UntilWithContext(ctx, func(_ context.Context, _ int) (bool, error) {
|
||||
describeTaskStatusReq := tcclb.NewDescribeTaskStatusRequest()
|
||||
describeTaskStatusReq.TaskId = modifyListenerResp.Response.RequestId
|
||||
describeTaskStatusResp, err := d.sdkClient.DescribeTaskStatus(describeTaskStatusReq)
|
||||
describeTaskStatusResp, err := d.sdkClient.DescribeTaskStatusWithContext(ctx, describeTaskStatusReq)
|
||||
d.logger.Debug("sdk request 'clb.DescribeTaskStatus'", slog.Any("request", describeTaskStatusReq), slog.Any("response", describeTaskStatusResp))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to execute sdk request 'clb.DescribeTaskStatus': %w", err)
|
||||
@@ -297,14 +296,14 @@ func (d *Deployer) updateListenerCertificate(ctx context.Context, cloudLoadbalan
|
||||
|
||||
d.logger.Info("waiting for tencentcloud task completion ...")
|
||||
return false, nil
|
||||
}, time.Second*5); err != nil {
|
||||
}, 10*time.Second); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(secretId, secretKey, endpoint, region string) (*internal.ClbClient, error) {
|
||||
func createSDKClient(secretId, secretKey, endpoint, region string) (*tcclb.Client, error) {
|
||||
credential := common.NewCredential(secretId, secretKey)
|
||||
|
||||
cpf := profile.NewClientProfile()
|
||||
@@ -312,7 +311,7 @@ func createSDKClient(secretId, secretKey, endpoint, region string) (*internal.Cl
|
||||
cpf.HttpProfile.Endpoint = endpoint
|
||||
}
|
||||
|
||||
client, err := internal.NewClbClient(credential, region, cpf)
|
||||
client, err := tcclb.NewClient(credential, region, cpf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user