mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
refactor: clean code
This commit is contained in:
@@ -29,8 +29,8 @@ type CertmgrConfig struct {
|
||||
AccessKeySecret string `json:"accessKeySecret"`
|
||||
// 移动云资源池 ID。
|
||||
PoolId string `json:"poolId"`
|
||||
// 是否是 SNI 证书。
|
||||
IsSNI bool `json:"isSni,omitempty"`
|
||||
// 是否设为默认证书。
|
||||
IsDefault bool `json:"isDefault,omitempty"`
|
||||
}
|
||||
|
||||
type Certmgr struct {
|
||||
@@ -124,7 +124,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*Uplo
|
||||
createLoadbalanceCertificationReq := &model.CreateLoadbalanceCertificationRequest{
|
||||
&model.CreateLoadbalanceCertificationBody{
|
||||
Name: lo.ToPtr(certName),
|
||||
Type: lo.ToPtr(lo.Ternary(c.config.IsSNI, model.CreateLoadbalanceCertificationBodyTypeEnumSni, model.CreateLoadbalanceCertificationBodyTypeEnumServer)),
|
||||
Type: lo.ToPtr(lo.Ternary(c.config.IsDefault, model.CreateLoadbalanceCertificationBodyTypeEnumServer, model.CreateLoadbalanceCertificationBodyTypeEnumSni)),
|
||||
Description: lo.ToPtr("upload from Certimate"),
|
||||
PublicKey: lo.ToPtr(certPEM),
|
||||
PrivateKey: lo.ToPtr(privkeyPEM),
|
||||
|
||||
@@ -42,6 +42,7 @@ func TestProvider(t *testing.T) {
|
||||
AccessKeyId: fAccessKeyId,
|
||||
AccessKeySecret: fAccessKeySecret,
|
||||
PoolId: fPoolId,
|
||||
IsDefault: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("err: %+v", err)
|
||||
|
||||
@@ -64,7 +64,7 @@ func NewDeployer(config *DeployerConfig) (*Deployer, error) {
|
||||
AccessKeyId: config.AccessKeyId,
|
||||
AccessKeySecret: config.AccessKeySecret,
|
||||
PoolId: config.PoolId,
|
||||
IsSNI: config.Domain != "",
|
||||
IsDefault: config.Domain == "",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create certmgr: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user