This commit is contained in:
Fu Diwei
2024-10-19 10:02:31 +08:00
parent 4382474449
commit 6225969d4c
9 changed files with 38 additions and 31 deletions

View File

@@ -20,7 +20,7 @@ type AliyunCDNDeployer struct {
infos []string
}
func NewAliyunCdnDeployer(option *DeployerOption) (*AliyunCDNDeployer, error) {
func NewAliyunCDNDeployer(option *DeployerOption) (*AliyunCDNDeployer, error) {
access := &domain.AliyunAccess{}
json.Unmarshal([]byte(option.Access), access)

View File

@@ -25,7 +25,7 @@ type AliyunESADeployer struct {
infos []string
}
func NewAliyunEsaDeployer(option *DeployerOption) (*AliyunESADeployer, error) {
func NewAliyunESADeployer(option *DeployerOption) (*AliyunESADeployer, error) {
access := &domain.AliyunAccess{}
json.Unmarshal([]byte(option.Access), access)

View File

@@ -16,7 +16,7 @@ type AliyunOSSDeployer struct {
infos []string
}
func NewAliyunOssDeployer(option *DeployerOption) (Deployer, error) {
func NewAliyunOSSDeployer(option *DeployerOption) (Deployer, error) {
access := &domain.AliyunAccess{}
json.Unmarshal([]byte(option.Access), access)

View File

@@ -97,11 +97,11 @@ func getWithDeployConfig(record *models.Record, cert *applicant.Certificate, dep
switch deployConfig.Type {
case targetAliyunOSS:
return NewAliyunOssDeployer(option)
return NewAliyunOSSDeployer(option)
case targetAliyunCDN:
return NewAliyunCdnDeployer(option)
return NewAliyunCDNDeployer(option)
case targetAliyunESA:
return NewAliyunEsaDeployer(option)
return NewAliyunESADeployer(option)
case targetTencentCDN:
return NewTencentCDNDeployer(option)
case targetQiniuCdn:

View File

@@ -8,11 +8,9 @@ import (
k8sMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
type KubernetesAccess struct {
KubeConfig string `json:"kubeConfig"`
}
"certimate/internal/domain"
)
type K8sSecretDeployer struct {
option *DeployerOption
@@ -35,7 +33,7 @@ func (d *K8sSecretDeployer) GetInfo() []string {
}
func (d *K8sSecretDeployer) Deploy(ctx context.Context) error {
access := &KubernetesAccess{}
access := &domain.KubernetesAccess{}
if err := json.Unmarshal([]byte(d.option.Access), access); err != nil {
return err
}
@@ -86,7 +84,7 @@ func (d *K8sSecretDeployer) Deploy(ctx context.Context) error {
return nil
}
func (d *K8sSecretDeployer) createClient(access *KubernetesAccess) (*kubernetes.Clientset, error) {
func (d *K8sSecretDeployer) createClient(access *domain.KubernetesAccess) (*kubernetes.Clientset, error) {
kubeConfig, err := clientcmd.Load([]byte(access.KubeConfig))
if err != nil {
return nil, err

View File

@@ -8,9 +8,9 @@ import (
"os/exec"
"path/filepath"
"runtime"
)
type LocalAccess struct{}
"certimate/internal/domain"
)
type LocalDeployer struct {
option *DeployerOption
@@ -33,7 +33,7 @@ func (d *LocalDeployer) GetInfo() []string {
}
func (d *LocalDeployer) Deploy(ctx context.Context) error {
access := &LocalAccess{}
access := &domain.LocalAccess{}
if err := json.Unmarshal([]byte(d.option.Access), access); err != nil {
return err
}

View File

@@ -10,16 +10,9 @@ import (
"github.com/pkg/sftp"
sshPkg "golang.org/x/crypto/ssh"
)
type SSHAccess struct {
Host string `json:"host"`
Port string `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Key string `json:"key"`
KeyPassphrase string `json:"keyPassphrase"`
}
"certimate/internal/domain"
)
type SSHDeployer struct {
option *DeployerOption
@@ -42,7 +35,7 @@ func (d *SSHDeployer) GetInfo() []string {
}
func (d *SSHDeployer) Deploy(ctx context.Context) error {
access := &SSHAccess{}
access := &domain.SSHAccess{}
if err := json.Unmarshal([]byte(d.option.Access), access); err != nil {
return err
}
@@ -130,7 +123,7 @@ func (d *SSHDeployer) upload(client *sshPkg.Client, content, path string) error
return nil
}
func (d *SSHDeployer) createClient(access *SSHAccess) (*sshPkg.Client, error) {
func (d *SSHDeployer) createClient(access *domain.SSHAccess) (*sshPkg.Client, error) {
var authMethod sshPkg.AuthMethod
if access.Key != "" {

View File

@@ -7,13 +7,10 @@ import (
"fmt"
"net/http"
"certimate/internal/domain"
xhttp "certimate/internal/utils/http"
)
type WebhookAccess struct {
Url string `json:"url"`
}
type WebhookDeployer struct {
option *DeployerOption
infos []string
@@ -42,7 +39,7 @@ type webhookData struct {
}
func (d *WebhookDeployer) Deploy(ctx context.Context) error {
access := &WebhookAccess{}
access := &domain.WebhookAccess{}
if err := json.Unmarshal([]byte(d.option.Access), access); err != nil {
return fmt.Errorf("failed to parse hook access config: %w", err)
}

View File

@@ -40,3 +40,22 @@ type GodaddyAccess struct {
ApiKey string `json:"apiKey"`
ApiSecret string `json:"apiSecret"`
}
type LocalAccess struct{}
type SSHAccess struct {
Host string `json:"host"`
Port string `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Key string `json:"key"`
KeyPassphrase string `json:"keyPassphrase"`
}
type WebhookAccess struct {
Url string `json:"url"`
}
type KubernetesAccess struct {
KubeConfig string `json:"kubeConfig"`
}