mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
feat: add Deployer
factory
This commit is contained in:
parent
30b66adc3b
commit
4916757d59
@ -20,7 +20,7 @@ func NewVolcengine(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *volcengine) Apply() (*Certificate, error) {
|
func (a *volcengine) Apply() (*Certificate, error) {
|
||||||
access := &domain.VolcengineAccess{}
|
access := &domain.VolcEngineAccess{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.Access), access)
|
||||||
|
|
||||||
os.Setenv("VOLC_ACCESSKEY", access.AccessKeyId)
|
os.Setenv("VOLC_ACCESSKEY", access.AccessKeyId)
|
||||||
|
@ -28,15 +28,15 @@ const (
|
|||||||
targetHuaweiCloudCDN = "huaweicloud-cdn"
|
targetHuaweiCloudCDN = "huaweicloud-cdn"
|
||||||
targetHuaweiCloudELB = "huaweicloud-elb"
|
targetHuaweiCloudELB = "huaweicloud-elb"
|
||||||
targetBaiduCloudCDN = "baiducloud-cdn"
|
targetBaiduCloudCDN = "baiducloud-cdn"
|
||||||
|
targetVolcEngineLive = "volcengine-live"
|
||||||
|
targetVolcEngineCDN = "volcengine-cdn"
|
||||||
|
targetBytePlusCDN = "byteplus-cdn"
|
||||||
targetQiniuCdn = "qiniu-cdn"
|
targetQiniuCdn = "qiniu-cdn"
|
||||||
targetDogeCloudCdn = "dogecloud-cdn"
|
targetDogeCloudCdn = "dogecloud-cdn"
|
||||||
targetLocal = "local"
|
targetLocal = "local"
|
||||||
targetSSH = "ssh"
|
targetSSH = "ssh"
|
||||||
targetWebhook = "webhook"
|
targetWebhook = "webhook"
|
||||||
targetK8sSecret = "k8s-secret"
|
targetK8sSecret = "k8s-secret"
|
||||||
targetVolcengineLive = "volcengine-live"
|
|
||||||
targetVolcengineCDN = "volcengine-cdn"
|
|
||||||
targetByteplusCDN = "byteplus-cdn"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeployerOption struct {
|
type DeployerOption struct {
|
||||||
@ -147,11 +147,11 @@ func getWithDeployConfig(record *models.Record, cert *applicant.Certificate, dep
|
|||||||
return NewWebhookDeployer(option)
|
return NewWebhookDeployer(option)
|
||||||
case targetK8sSecret:
|
case targetK8sSecret:
|
||||||
return NewK8sSecretDeployer(option)
|
return NewK8sSecretDeployer(option)
|
||||||
case targetVolcengineLive:
|
case targetVolcEngineLive:
|
||||||
return NewVolcengineLiveDeployer(option)
|
return NewVolcengineLiveDeployer(option)
|
||||||
case targetVolcengineCDN:
|
case targetVolcEngineCDN:
|
||||||
return NewVolcengineCDNDeployer(option)
|
return NewVolcengineCDNDeployer(option)
|
||||||
case targetByteplusCDN:
|
case targetBytePlusCDN:
|
||||||
return NewByteplusCDNDeployer(option)
|
return NewByteplusCDNDeployer(option)
|
||||||
}
|
}
|
||||||
return nil, errors.New("unsupported deploy target")
|
return nil, errors.New("unsupported deploy target")
|
||||||
|
@ -3,10 +3,33 @@ package deployer
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/pkg/core/deployer"
|
"github.com/usual2970/certimate/internal/pkg/core/deployer"
|
||||||
|
providerAliyunAlb "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-alb"
|
||||||
|
providerAliyunCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-cdn"
|
||||||
|
providerAliyunClb "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-clb"
|
||||||
|
providerAliyunDcdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-dcdn"
|
||||||
|
providerAliyunNlb "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-nlb"
|
||||||
providerAliyunOss "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-oss"
|
providerAliyunOss "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/aliyun-oss"
|
||||||
|
providerBaiduCloudCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/baiducloud-cdn"
|
||||||
|
providerBytePlusCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/byteplus-cdn"
|
||||||
|
providerDogeCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/dogecloud-cdn"
|
||||||
|
providerHuaweiCloudCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/huaweicloud-cdn"
|
||||||
|
providerHuaweiCloudElb "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/huaweicloud-elb"
|
||||||
|
providerK8sSecret "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/k8s-secret"
|
||||||
|
providerLocal "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/local"
|
||||||
|
providerQiniuCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/qiniu-cdn"
|
||||||
|
providerSSH "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/ssh"
|
||||||
|
providerTencentCloudCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/tencentcloud-cdn"
|
||||||
|
providerTencentCloudClb "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/tencentcloud-clb"
|
||||||
|
providerTencentCloudCos "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/tencentcloud-cos"
|
||||||
|
providerTencentCloudEcdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/tencentcloud-ecdn"
|
||||||
|
providerTencentCloudTeo "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/tencentcloud-teo"
|
||||||
|
providerVolcEngineCdn "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/volcengine-cdn"
|
||||||
|
providerVolcEngineLive "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/volcengine-live"
|
||||||
|
providerWebhook "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/webhook"
|
||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,20 +38,336 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
logger := deployer.NewDefaultLogger()
|
logger := deployer.NewDefaultLogger()
|
||||||
|
|
||||||
switch target {
|
switch target {
|
||||||
case targetAliyunOSS:
|
case targetAliyunALB, targetAliyunCDN, targetAliyunCLB, targetAliyunDCDN, targetAliyunNLB, targetAliyunOSS:
|
||||||
access := &domain.AliyunAccess{}
|
{
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
access := &domain.AliyunAccess{}
|
||||||
return nil, nil, err
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch target {
|
||||||
|
case targetAliyunALB:
|
||||||
|
deployer, err := providerAliyunAlb.NewWithLogger(&providerAliyunAlb.AliyunALBDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
ResourceType: providerAliyunAlb.DeployResourceType(maps.GetValueAsString(deployConfig, "resourceType")),
|
||||||
|
LoadbalancerId: maps.GetValueAsString(deployConfig, "loadbalancerId"),
|
||||||
|
ListenerId: maps.GetValueAsString(deployConfig, "listenerId"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetAliyunCDN:
|
||||||
|
deployer, err := providerAliyunCdn.NewWithLogger(&providerAliyunCdn.AliyunCDNDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetAliyunCLB:
|
||||||
|
deployer, err := providerAliyunClb.NewWithLogger(&providerAliyunClb.AliyunCLBDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
ResourceType: providerAliyunClb.DeployResourceType(maps.GetValueAsString(deployConfig, "resourceType")),
|
||||||
|
LoadbalancerId: maps.GetValueAsString(deployConfig, "loadbalancerId"),
|
||||||
|
ListenerPort: maps.GetValueAsInt32(deployConfig, "listenerPort"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetAliyunDCDN:
|
||||||
|
deployer, err := providerAliyunDcdn.NewWithLogger(&providerAliyunDcdn.AliyunDCDNDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetAliyunNLB:
|
||||||
|
deployer, err := providerAliyunNlb.NewWithLogger(&providerAliyunNlb.AliyunNLBDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
ResourceType: providerAliyunNlb.DeployResourceType(maps.GetValueAsString(deployConfig, "resourceType")),
|
||||||
|
LoadbalancerId: maps.GetValueAsString(deployConfig, "loadbalancerId"),
|
||||||
|
ListenerId: maps.GetValueAsString(deployConfig, "listenerId"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetAliyunOSS:
|
||||||
|
deployer, err := providerAliyunOss.NewWithLogger(&providerAliyunOss.AliyunOSSDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
AccessKeySecret: access.AccessKeySecret,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
Bucket: maps.GetValueAsString(deployConfig, "bucket"),
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deployer, err := providerAliyunOss.NewWithLogger(&providerAliyunOss.AliyunOSSDeployerConfig{
|
case targetBaiduCloudCDN:
|
||||||
AccessKeyId: access.AccessKeyId,
|
{
|
||||||
AccessKeySecret: access.AccessKeySecret,
|
access := &domain.BaiduCloudAccess{}
|
||||||
Region: maps.GetValueAsString(deployConfig, "region"),
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
Bucket: maps.GetValueAsString(deployConfig, "bucket"),
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
}
|
||||||
}, logger)
|
|
||||||
return deployer, logger, err
|
deployer, err := providerBaiduCloudCdn.NewWithLogger(&providerBaiduCloudCdn.BaiduCloudCDNDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
SecretAccessKey: access.SecretAccessKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetBytePlusCDN:
|
||||||
|
{
|
||||||
|
access := &domain.ByteplusAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deployer, err := providerBytePlusCdn.NewWithLogger(&providerBytePlusCdn.BytePlusCDNDeployerConfig{
|
||||||
|
AccessKey: access.AccessKey,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetDogeCloudCdn:
|
||||||
|
{
|
||||||
|
access := &domain.DogeCloudAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deployer, err := providerDogeCdn.NewWithLogger(&providerDogeCdn.DogeCloudCDNDeployerConfig{
|
||||||
|
AccessKey: access.AccessKey,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetHuaweiCloudCDN, targetHuaweiCloudELB:
|
||||||
|
{
|
||||||
|
access := &domain.HuaweiCloudAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch target {
|
||||||
|
case targetHuaweiCloudCDN:
|
||||||
|
deployer, err := providerHuaweiCloudCdn.NewWithLogger(&providerHuaweiCloudCdn.HuaweiCloudCDNDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
SecretAccessKey: access.SecretAccessKey,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetHuaweiCloudELB:
|
||||||
|
deployer, err := providerHuaweiCloudElb.NewWithLogger(&providerHuaweiCloudElb.HuaweiCloudELBDeployerConfig{
|
||||||
|
AccessKeyId: access.AccessKeyId,
|
||||||
|
SecretAccessKey: access.SecretAccessKey,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
ResourceType: providerHuaweiCloudElb.DeployResourceType(maps.GetValueAsString(deployConfig, "resourceType")),
|
||||||
|
CertificateId: maps.GetValueAsString(deployConfig, "certificateId"),
|
||||||
|
LoadbalancerId: maps.GetValueAsString(deployConfig, "loadbalancerId"),
|
||||||
|
ListenerId: maps.GetValueAsString(deployConfig, "listenerId"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetLocal:
|
||||||
|
{
|
||||||
|
deployer, err := providerLocal.NewWithLogger(&providerLocal.LocalDeployerConfig{
|
||||||
|
ShellEnv: providerLocal.ShellEnvType(maps.GetValueAsString(deployConfig, "shellEnv")),
|
||||||
|
PreCommand: maps.GetValueAsString(deployConfig, "preCommand"),
|
||||||
|
PostCommand: maps.GetValueAsString(deployConfig, "postCommand"),
|
||||||
|
OutputFormat: providerLocal.OutputFormatType(maps.GetValueOrDefaultAsString(deployConfig, "outputFormat", "PEM")),
|
||||||
|
OutputCertPath: maps.GetValueAsString(deployConfig, "outputCertPath"),
|
||||||
|
OutputKeyPath: maps.GetValueAsString(deployConfig, "outputKeyPath"),
|
||||||
|
PfxPassword: maps.GetValueAsString(deployConfig, "pfxPassword"),
|
||||||
|
JksAlias: maps.GetValueAsString(deployConfig, "jksAlias"),
|
||||||
|
JksKeypass: maps.GetValueAsString(deployConfig, "jksKeypass"),
|
||||||
|
JksStorepass: maps.GetValueAsString(deployConfig, "jksStorepass"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetK8sSecret:
|
||||||
|
{
|
||||||
|
access := &domain.KubernetesAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deployer, err := providerK8sSecret.NewWithLogger(&providerK8sSecret.K8sSecretDeployerConfig{
|
||||||
|
KubeConfig: access.KubeConfig,
|
||||||
|
Namespace: maps.GetValueOrDefaultAsString(deployConfig, "namespace", "default"),
|
||||||
|
SecretName: maps.GetValueAsString(deployConfig, "secretName"),
|
||||||
|
SecretDataKeyForCrt: maps.GetValueOrDefaultAsString(deployConfig, "secretDataKeyForCrt", "tls.crt"),
|
||||||
|
SecretDataKeyForKey: maps.GetValueOrDefaultAsString(deployConfig, "secretDataKeyForKey", "tls.key"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetQiniuCdn:
|
||||||
|
{
|
||||||
|
access := &domain.QiniuAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deployer, err := providerQiniuCdn.NewWithLogger(&providerQiniuCdn.QiniuCDNDeployerConfig{
|
||||||
|
AccessKey: access.AccessKey,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetSSH:
|
||||||
|
{
|
||||||
|
access := &domain.SSHAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sshPort, _ := strconv.ParseInt(access.Port, 10, 32)
|
||||||
|
deployer, err := providerSSH.NewWithLogger(&providerSSH.SshDeployerConfig{
|
||||||
|
SshHost: access.Host,
|
||||||
|
SshPort: int32(sshPort),
|
||||||
|
SshUsername: access.Username,
|
||||||
|
SshPassword: access.Password,
|
||||||
|
SshKey: access.Key,
|
||||||
|
SshKeyPassphrase: access.KeyPassphrase,
|
||||||
|
PreCommand: maps.GetValueAsString(deployConfig, "preCommand"),
|
||||||
|
PostCommand: maps.GetValueAsString(deployConfig, "postCommand"),
|
||||||
|
OutputFormat: providerSSH.OutputFormatType(maps.GetValueOrDefaultAsString(deployConfig, "outputFormat", "PEM")),
|
||||||
|
OutputCertPath: maps.GetValueAsString(deployConfig, "outputCertPath"),
|
||||||
|
OutputKeyPath: maps.GetValueAsString(deployConfig, "outputKeyPath"),
|
||||||
|
PfxPassword: maps.GetValueAsString(deployConfig, "pfxPassword"),
|
||||||
|
JksAlias: maps.GetValueAsString(deployConfig, "jksAlias"),
|
||||||
|
JksKeypass: maps.GetValueAsString(deployConfig, "jksKeypass"),
|
||||||
|
JksStorepass: maps.GetValueAsString(deployConfig, "jksStorepass"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetTencentCDN, targetTencentCLB, targetTencentCOS, targetTencentECDN, targetTencentTEO:
|
||||||
|
{
|
||||||
|
access := &domain.TencentAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch target {
|
||||||
|
case targetTencentCDN:
|
||||||
|
deployer, err := providerTencentCloudCdn.NewWithLogger(&providerTencentCloudCdn.TencentCloudCDNDeployerConfig{
|
||||||
|
SecretId: access.SecretId,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetTencentCLB:
|
||||||
|
deployer, err := providerTencentCloudClb.NewWithLogger(&providerTencentCloudClb.TencentCloudCLBDeployerConfig{
|
||||||
|
SecretId: access.SecretId,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
ResourceType: providerTencentCloudClb.DeployResourceType(maps.GetValueAsString(deployConfig, "resourceType")),
|
||||||
|
LoadbalancerId: maps.GetValueAsString(deployConfig, "loadbalancerId"),
|
||||||
|
ListenerId: maps.GetValueAsString(deployConfig, "listenerId"),
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetTencentCOS:
|
||||||
|
deployer, err := providerTencentCloudCos.NewWithLogger(&providerTencentCloudCos.TencentCloudCOSDeployerConfig{
|
||||||
|
SecretId: access.SecretId,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Region: maps.GetValueAsString(deployConfig, "region"),
|
||||||
|
Bucket: maps.GetValueAsString(deployConfig, "bucket"),
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetTencentECDN:
|
||||||
|
deployer, err := providerTencentCloudEcdn.NewWithLogger(&providerTencentCloudEcdn.TencentCloudECDNDeployerConfig{
|
||||||
|
SecretId: access.SecretId,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetTencentTEO:
|
||||||
|
deployer, err := providerTencentCloudTeo.NewWithLogger(&providerTencentCloudTeo.TencentCloudTEODeployerConfig{
|
||||||
|
SecretId: access.SecretId,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
ZoneId: maps.GetValueAsString(deployConfig, "zoneId"),
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetVolcEngineCDN, targetVolcEngineLive:
|
||||||
|
{
|
||||||
|
access := &domain.VolcEngineAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch target {
|
||||||
|
case targetVolcEngineCDN:
|
||||||
|
deployer, err := providerVolcEngineCdn.NewWithLogger(&providerVolcEngineCdn.VolcEngineCDNDeployerConfig{
|
||||||
|
AccessKey: access.AccessKey,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
case targetVolcEngineLive:
|
||||||
|
deployer, err := providerVolcEngineLive.NewWithLogger(&providerVolcEngineLive.VolcEngineLiveDeployerConfig{
|
||||||
|
AccessKey: access.AccessKey,
|
||||||
|
SecretKey: access.SecretKey,
|
||||||
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case targetWebhook:
|
||||||
|
{
|
||||||
|
access := &domain.WebhookAccess{}
|
||||||
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deployer, err := providerWebhook.NewWithLogger(&providerWebhook.WebhookDeployerConfig{
|
||||||
|
Url: access.Url,
|
||||||
|
Variables: nil, // TODO: 尚未实现
|
||||||
|
}, logger)
|
||||||
|
return deployer, logger, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil, fmt.Errorf("unsupported deployer target: %s", target)
|
return nil, nil, fmt.Errorf("unsupported deployer target: %s", target)
|
||||||
|
@ -22,7 +22,7 @@ type VolcengineCDNDeployer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewVolcengineCDNDeployer(option *DeployerOption) (Deployer, error) {
|
func NewVolcengineCDNDeployer(option *DeployerOption) (Deployer, error) {
|
||||||
access := &domain.VolcengineAccess{}
|
access := &domain.VolcEngineAccess{}
|
||||||
if err := json.Unmarshal([]byte(option.Access), access); err != nil {
|
if err := json.Unmarshal([]byte(option.Access), access); err != nil {
|
||||||
return nil, xerrors.Wrap(err, "failed to get access")
|
return nil, xerrors.Wrap(err, "failed to get access")
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ type VolcengineLiveDeployer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewVolcengineLiveDeployer(option *DeployerOption) (Deployer, error) {
|
func NewVolcengineLiveDeployer(option *DeployerOption) (Deployer, error) {
|
||||||
access := &domain.VolcengineAccess{}
|
access := &domain.VolcEngineAccess{}
|
||||||
if err := json.Unmarshal([]byte(option.Access), access); err != nil {
|
if err := json.Unmarshal([]byte(option.Access), access); err != nil {
|
||||||
return nil, xerrors.Wrap(err, "failed to get access")
|
return nil, xerrors.Wrap(err, "failed to get access")
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ type PdnsAccess struct {
|
|||||||
ApiKey string `json:"apiKey"`
|
ApiKey string `json:"apiKey"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VolcengineAccess struct {
|
type VolcEngineAccess struct {
|
||||||
AccessKey string `json:"accessKey"`
|
AccessKey string `json:"accessKey"`
|
||||||
SecretKey string `json:"secretKey"`
|
SecretKey string `json:"secretKey"`
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user