mirror of
https://github.com/usual2970/certimate.git
synced 2025-09-20 06:56:01 +00:00
refactor: clean code
This commit is contained in:
@@ -2,7 +2,6 @@ package deployer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/usual2970/certimate/internal/applicant"
|
||||
"github.com/usual2970/certimate/internal/domain"
|
||||
@@ -10,39 +9,6 @@ import (
|
||||
"github.com/usual2970/certimate/internal/pkg/core/logger"
|
||||
)
|
||||
|
||||
/*
|
||||
提供商部署目标常量值。
|
||||
短横线前的部分始终等于提供商类型。
|
||||
|
||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||
NOTICE: If you add new constant, please keep ASCII order.
|
||||
*/
|
||||
const (
|
||||
targetAliyunALB = "aliyun-alb"
|
||||
targetAliyunCDN = "aliyun-cdn"
|
||||
targetAliyunCLB = "aliyun-clb"
|
||||
targetAliyunDCDN = "aliyun-dcdn"
|
||||
targetAliyunNLB = "aliyun-nlb"
|
||||
targetAliyunOSS = "aliyun-oss"
|
||||
targetBaiduCloudCDN = "baiducloud-cdn"
|
||||
targetBytePlusCDN = "byteplus-cdn"
|
||||
targetDogeCloudCDN = "dogecloud-cdn"
|
||||
targetHuaweiCloudCDN = "huaweicloud-cdn"
|
||||
targetHuaweiCloudELB = "huaweicloud-elb"
|
||||
targetK8sSecret = "k8s-secret"
|
||||
targetLocal = "local"
|
||||
targetQiniuCDN = "qiniu-cdn"
|
||||
targetSSH = "ssh"
|
||||
targetTencentCloudCDN = "tencentcloud-cdn"
|
||||
targetTencentCloudCLB = "tencentcloud-clb"
|
||||
targetTencentCloudCOS = "tencentcloud-cos"
|
||||
targetTencentCloudECDN = "tencentcloud-ecdn"
|
||||
targetTencentCloudEO = "tencentcloud-eo"
|
||||
targetVolcEngineCDN = "volcengine-cdn"
|
||||
targetVolcEngineLive = "volcengine-live"
|
||||
targetWebhook = "webhook"
|
||||
)
|
||||
|
||||
type DeployerOption struct {
|
||||
NodeId string `json:"nodeId"`
|
||||
Domains string `json:"domains"`
|
||||
@@ -50,17 +16,14 @@ type DeployerOption struct {
|
||||
AccessRecord *domain.Access `json:"-"`
|
||||
DeployConfig domain.DeployConfig `json:"deployConfig"`
|
||||
Certificate applicant.Certificate `json:"certificate"`
|
||||
Variables map[string]string `json:"variables"`
|
||||
}
|
||||
|
||||
type Deployer interface {
|
||||
Deploy(ctx context.Context) error
|
||||
GetInfos() []string
|
||||
GetID() string
|
||||
}
|
||||
|
||||
func GetWithTypeAndOption(deployType string, option *DeployerOption) (Deployer, error) {
|
||||
deployer, logger, err := createDeployer(deployType, option.AccessRecord.Config, option.DeployConfig.NodeConfig)
|
||||
func GetWithProviderAndOption(provider string, option *DeployerOption) (Deployer, error) {
|
||||
deployer, logger, err := createDeployer(domain.DeployProviderType(provider), option.AccessRecord.Config, option.DeployConfig.NodeConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -79,14 +42,6 @@ type proxyDeployer struct {
|
||||
deployer deployer.Deployer
|
||||
}
|
||||
|
||||
func (d *proxyDeployer) GetID() string {
|
||||
return fmt.Sprintf("%s-%s", d.option.AccessRecord.Name, d.option.AccessRecord.Id)
|
||||
}
|
||||
|
||||
func (d *proxyDeployer) GetInfos() []string {
|
||||
return d.logger.GetRecords()
|
||||
}
|
||||
|
||||
func (d *proxyDeployer) Deploy(ctx context.Context) error {
|
||||
_, err := d.deployer.Deploy(ctx, d.option.Certificate.Certificate, d.option.Certificate.PrivateKey)
|
||||
return err
|
||||
|
Reference in New Issue
Block a user