mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
feat: update access fields to AccessKeyId and SecretAccessKey for byteplus services
This commit is contained in:
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type ChallengerConfig struct {
|
||||
AccessKey string `json:"accessKey"`
|
||||
SecretKey string `json:"secretKey"`
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
DnsPropagationTimeout int `json:"dnsPropagationTimeout,omitempty"`
|
||||
DnsTTL int `json:"dnsTTL,omitempty"`
|
||||
}
|
||||
@@ -22,8 +22,8 @@ func NewChallenger(config *ChallengerConfig) (certifier.ACMEChallenger, error) {
|
||||
}
|
||||
|
||||
providerConfig := internal.NewDefaultConfig()
|
||||
providerConfig.AccessKey = config.AccessKey
|
||||
providerConfig.SecretKey = config.SecretKey
|
||||
providerConfig.AccessKey = config.AccessKeyId
|
||||
providerConfig.SecretKey = config.SecretAccessKey
|
||||
if config.DnsPropagationTimeout != 0 {
|
||||
providerConfig.PropagationTimeout = time.Duration(config.DnsPropagationTimeout) * time.Second
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ import (
|
||||
)
|
||||
|
||||
type CertmgrConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus AccessKeyId。
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
// BytePlus SecretAccessKey。
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
}
|
||||
|
||||
type Certmgr struct {
|
||||
@@ -37,8 +37,8 @@ func NewCertmgr(config *CertmgrConfig) (*Certmgr, error) {
|
||||
}
|
||||
|
||||
client := bpcdn.NewInstance()
|
||||
client.Client.SetAccessKey(config.AccessKey)
|
||||
client.Client.SetSecretKey(config.SecretKey)
|
||||
client.Client.SetAccessKey(config.AccessKeyId)
|
||||
client.Client.SetSecretKey(config.SecretAccessKey)
|
||||
|
||||
return &Certmgr{
|
||||
config: config,
|
||||
|
||||
@@ -8,18 +8,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fp = tester.Args("BYTEPLUSCDN_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
fp = tester.Args("BYTEPLUSCDN_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
)
|
||||
|
||||
func init() {
|
||||
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
|
||||
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
|
||||
fp.DefineString(&fAccessKey, "ACCESSKEY")
|
||||
fp.DefineString(&fSecretKey, "SECRETKEY")
|
||||
fp.DefineString(&fAccessKeyId, "ACCESSKEYID")
|
||||
fp.DefineString(&fSecretAccessKey, "SECRETACCESSKEY")
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -28,16 +28,16 @@ Shell command to run this test:
|
||||
go test -v ./byteplus_cdn_test.go -args \
|
||||
--BYTEPLUSCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
|
||||
--BYTEPLUSCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
|
||||
--BYTEPLUSCDN_ACCESSKEY="your-access-key" \
|
||||
--BYTEPLUSCDN_SECRETKEY="your-secret-key"
|
||||
--BYTEPLUSCDN_ACCESSKEYID="your-access-key-id" \
|
||||
--BYTEPLUSCDN_SECRETACCESSKEY="your-secret-access-key"
|
||||
*/
|
||||
func TestProvider(t *testing.T) {
|
||||
fp.Parse()
|
||||
|
||||
t.Run("Upload", func(t *testing.T) {
|
||||
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
|
||||
@@ -14,10 +14,10 @@ import (
|
||||
)
|
||||
|
||||
type CertmgrConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus AccessKeyId。
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
// BytePlus SecretAccessKey。
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
// BytePlus 项目名称。
|
||||
ProjectName string `json:"projectName,omitempty"`
|
||||
// BytePlus 地域。
|
||||
@@ -37,7 +37,7 @@ func NewCertmgr(config *CertmgrConfig) (*Certmgr, error) {
|
||||
return nil, fmt.Errorf("the configuration of the certmgr provider is nil")
|
||||
}
|
||||
|
||||
client, err := createSDKClient(config.AccessKey, config.SecretKey, config.Region)
|
||||
client, err := createSDKClient(config.AccessKeyId, config.SecretAccessKey, config.Region)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create client: %w", err)
|
||||
}
|
||||
@@ -95,13 +95,13 @@ func (c *Certmgr) Replace(ctx context.Context, certIdOrName string, certPEM, pri
|
||||
return nil, certmgr.ErrUnsupported
|
||||
}
|
||||
|
||||
func createSDKClient(accessKey, secretKey, region string) (*bpcertificateservice.CERTIFICATESERVICE, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*bpcertificateservice.CERTIFICATESERVICE, error) {
|
||||
if region == "" {
|
||||
region = "ap-singapore-1" // 证书中心默认区域:新加坡
|
||||
}
|
||||
|
||||
config := bp.NewConfig().
|
||||
WithAkSk(accessKey, secretKey).
|
||||
WithAkSk(accessKeyId, secretAccessKey).
|
||||
WithRegion(region)
|
||||
|
||||
session, err := bpsesion.NewSession(config)
|
||||
|
||||
@@ -8,18 +8,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fp = tester.Args("BYTEPLUSCERTCENTER_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
fp = tester.Args("BYTEPLUSCERTCENTER_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
)
|
||||
|
||||
func init() {
|
||||
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
|
||||
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
|
||||
fp.DefineString(&fAccessKey, "ACCESSKEY")
|
||||
fp.DefineString(&fSecretKey, "SECRETKEY")
|
||||
fp.DefineString(&fAccessKeyId, "ACCESSKEYID")
|
||||
fp.DefineString(&fSecretAccessKey, "SECRETACCESSKEY")
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -28,16 +28,16 @@ Shell command to run this test:
|
||||
go test -v ./byteplus_certcenter_test.go -args \
|
||||
--BYTEPLUSCERTCENTER_TESTCERTPATH="/path/to/your-test-cert.pem" \
|
||||
--BYTEPLUSCERTCENTER_TESTKEYPATH="/path/to/your-test-key.pem" \
|
||||
--BYTEPLUSCERTCENTER_ACCESSKEY="your-access-key" \
|
||||
--BYTEPLUSCERTCENTER_SECRETKEY="your-secret-key"
|
||||
--BYTEPLUSCERTCENTER_ACCESSKEYID="your-access-key-id" \
|
||||
--BYTEPLUSCERTCENTER_SECRETACCESSKEY="your-secret-access-key"
|
||||
*/
|
||||
func TestProvider(t *testing.T) {
|
||||
fp.Parse()
|
||||
|
||||
t.Run("Upload", func(t *testing.T) {
|
||||
provider, err := impl.NewCertmgr(&impl.CertmgrConfig{
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
|
||||
@@ -17,10 +17,10 @@ import (
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus AccessKeyId。
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
// BytePlus SecretAccessKey。
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
// BytePlus 项目名称。
|
||||
ProjectName string `json:"projectName,omitempty"`
|
||||
// 域名匹配模式。
|
||||
@@ -45,12 +45,12 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
}
|
||||
|
||||
client := bpcdn.NewInstance()
|
||||
client.Client.SetAccessKey(config.AccessKey)
|
||||
client.Client.SetSecretKey(config.SecretKey)
|
||||
client.Client.SetAccessKey(config.AccessKeyId)
|
||||
client.Client.SetSecretKey(config.SecretAccessKey)
|
||||
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create certmgr: %w", err)
|
||||
|
||||
@@ -8,19 +8,19 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fp = tester.Args("BYTEPLUSCDN_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKey string
|
||||
fSecretKey string
|
||||
fDomain string
|
||||
fp = tester.Args("BYTEPLUSCDN_")
|
||||
fTestCertPath string
|
||||
fTestKeyPath string
|
||||
fAccessKeyId string
|
||||
fSecretAccessKey string
|
||||
fDomain string
|
||||
)
|
||||
|
||||
func init() {
|
||||
fp.DefineString(&fTestCertPath, "TESTCERTPATH")
|
||||
fp.DefineString(&fTestKeyPath, "TESTKEYPATH")
|
||||
fp.DefineString(&fAccessKey, "ACCESSKEY")
|
||||
fp.DefineString(&fSecretKey, "SECRETKEY")
|
||||
fp.DefineString(&fAccessKeyId, "ACCESSKEYID")
|
||||
fp.DefineString(&fSecretAccessKey, "SECRETACCESSKEY")
|
||||
fp.DefineString(&fDomain, "DOMAIN")
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ Shell command to run this test:
|
||||
go test -v ./byteplus_cdn_test.go -args \
|
||||
--BYTEPLUSCDN_TESTCERTPATH="/path/to/your-test-cert.pem" \
|
||||
--BYTEPLUSCDN_TESTKEYPATH="/path/to/your-test-key.pem" \
|
||||
--BYTEPLUSCDN_ACCESSKEY="your-access-key" \
|
||||
--BYTEPLUSCDN_SECRETKEY="your-secret-key" \
|
||||
--BYTEPLUSCDN_ACCESSKEYID="your-access-key-id" \
|
||||
--BYTEPLUSCDN_SECRETACCESSKEY="your-secret-access-key" \
|
||||
--BYTEPLUSCDN_DOMAIN="example.com"
|
||||
*/
|
||||
func TestProvider(t *testing.T) {
|
||||
@@ -39,9 +39,9 @@ func TestProvider(t *testing.T) {
|
||||
|
||||
t.Run("Deploy", func(t *testing.T) {
|
||||
provider, err := impl.NewDeployer(&impl.DeployerConfig{
|
||||
AccessKey: fAccessKey,
|
||||
SecretKey: fSecretKey,
|
||||
Domain: fDomain,
|
||||
AccessKeyId: fAccessKeyId,
|
||||
SecretAccessKey: fSecretAccessKey,
|
||||
Domain: fDomain,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
)
|
||||
|
||||
type DeployerConfig struct {
|
||||
// BytePlus AccessKey。
|
||||
AccessKey string `json:"accessKey"`
|
||||
// BytePlus SecretKey。
|
||||
SecretKey string `json:"secretKey"`
|
||||
// BytePlus AccessKeyId。
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
// BytePlus SecretAccessKey。
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
// BytePlus 项目名称。
|
||||
ProjectName string `json:"projectName,omitempty"`
|
||||
// BytePlus 地域。
|
||||
@@ -35,10 +35,10 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
}
|
||||
|
||||
pcertmgr, err := certmgrimpl.NewCertmgr(&certmgrimpl.CertmgrConfig{
|
||||
AccessKey: config.AccessKey,
|
||||
SecretKey: config.SecretKey,
|
||||
ProjectName: config.ProjectName,
|
||||
Region: config.Region,
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
SecretAccessKey: config.SecretAccessKey,
|
||||
ProjectName: config.ProjectName,
|
||||
Region: config.Region,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create certmgr: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user