mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-29 15:49:56 +00:00
refactor: clean code
This commit is contained in:
parent
047479426a
commit
86133ba52b
@ -21,8 +21,8 @@ func NewACMEHttpReqApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *acmeHttpReqApplicant) Apply() (*Certificate, error) {
|
func (a *acmeHttpReqApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.HttpreqAccess{}
|
access := &domain.ACMEHttpReqAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := httpreq.NewDefaultConfig()
|
config := httpreq.NewDefaultConfig()
|
||||||
endpoint, _ := url.Parse(access.Endpoint)
|
endpoint, _ := url.Parse(access.Endpoint)
|
||||||
|
@ -20,8 +20,8 @@ func NewAliyunApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *aliyunApplicant) Apply() (*Certificate, error) {
|
func (a *aliyunApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.AliyunAccess{}
|
access := &domain.AliyunAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := alidns.NewDefaultConfig()
|
config := alidns.NewDefaultConfig()
|
||||||
config.APIKey = access.AccessKeyId
|
config.APIKey = access.AccessKeyId
|
||||||
|
@ -26,26 +26,6 @@ import (
|
|||||||
"github.com/usual2970/certimate/internal/repository"
|
"github.com/usual2970/certimate/internal/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
|
||||||
提供商类型常量值。
|
|
||||||
|
|
||||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
|
||||||
NOTICE: If you add new constant, please keep ASCII order.
|
|
||||||
*/
|
|
||||||
const (
|
|
||||||
configTypeACMEHttpReq = "acmehttpreq"
|
|
||||||
configTypeAliyun = "aliyun"
|
|
||||||
configTypeAWS = "aws"
|
|
||||||
configTypeCloudflare = "cloudflare"
|
|
||||||
configTypeGoDaddy = "godaddy"
|
|
||||||
configTypeHuaweiCloud = "huaweicloud"
|
|
||||||
configTypeNameDotCom = "namedotcom"
|
|
||||||
configTypeNameSilo = "namesilo"
|
|
||||||
configTypePowerDNS = "powerdns"
|
|
||||||
configTypeTencentCloud = "tencentcloud"
|
|
||||||
configTypeVolcEngine = "volcengine"
|
|
||||||
)
|
|
||||||
|
|
||||||
const defaultSSLProvider = "letsencrypt"
|
const defaultSSLProvider = "letsencrypt"
|
||||||
const (
|
const (
|
||||||
sslProviderLetsencrypt = "letsencrypt"
|
sslProviderLetsencrypt = "letsencrypt"
|
||||||
@ -78,8 +58,8 @@ type Certificate struct {
|
|||||||
|
|
||||||
type ApplyOption struct {
|
type ApplyOption struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"subjectAltNames"`
|
||||||
Access string `json:"access"`
|
AccessConfig string `json:"accessConfig"`
|
||||||
KeyAlgorithm string `json:"keyAlgorithm"`
|
KeyAlgorithm string `json:"keyAlgorithm"`
|
||||||
Nameservers string `json:"nameservers"`
|
Nameservers string `json:"nameservers"`
|
||||||
PropagationTimeout int64 `json:"propagationTimeout"`
|
PropagationTimeout int64 `json:"propagationTimeout"`
|
||||||
@ -165,14 +145,14 @@ func Get(record *models.Record) (Applicant, error) {
|
|||||||
option := &ApplyOption{
|
option := &ApplyOption{
|
||||||
Email: applyConfig.Email,
|
Email: applyConfig.Email,
|
||||||
Domain: record.GetString("domain"),
|
Domain: record.GetString("domain"),
|
||||||
Access: access.GetString("config"),
|
AccessConfig: access.GetString("config"),
|
||||||
KeyAlgorithm: applyConfig.KeyAlgorithm,
|
KeyAlgorithm: applyConfig.KeyAlgorithm,
|
||||||
Nameservers: applyConfig.Nameservers,
|
Nameservers: applyConfig.Nameservers,
|
||||||
PropagationTimeout: applyConfig.PropagationTimeout,
|
PropagationTimeout: applyConfig.PropagationTimeout,
|
||||||
DisableFollowCNAME: applyConfig.DisableFollowCNAME,
|
DisableFollowCNAME: applyConfig.DisableFollowCNAME,
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetWithTypeOption(access.GetString("configType"), option)
|
return GetWithTypeOption(domain.AccessProviderType(access.GetString("configType")), option)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetWithApplyNode(node *domain.WorkflowNode) (Applicant, error) {
|
func GetWithApplyNode(node *domain.WorkflowNode) (Applicant, error) {
|
||||||
@ -187,46 +167,46 @@ func GetWithApplyNode(node *domain.WorkflowNode) (Applicant, error) {
|
|||||||
applyConfig := &ApplyOption{
|
applyConfig := &ApplyOption{
|
||||||
Email: node.GetConfigString("email"),
|
Email: node.GetConfigString("email"),
|
||||||
Domain: node.GetConfigString("domain"),
|
Domain: node.GetConfigString("domain"),
|
||||||
Access: access.Config,
|
AccessConfig: access.Config,
|
||||||
KeyAlgorithm: node.GetConfigString("keyAlgorithm"),
|
KeyAlgorithm: node.GetConfigString("keyAlgorithm"),
|
||||||
Nameservers: node.GetConfigString("nameservers"),
|
Nameservers: node.GetConfigString("nameservers"),
|
||||||
PropagationTimeout: node.GetConfigInt64("propagationTimeout"),
|
PropagationTimeout: node.GetConfigInt64("propagationTimeout"),
|
||||||
DisableFollowCNAME: node.GetConfigBool("disableFollowCNAME"),
|
DisableFollowCNAME: node.GetConfigBool("disableFollowCNAME"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetWithTypeOption(access.ConfigType, applyConfig)
|
return GetWithTypeOption(domain.AccessProviderType(access.ConfigType), applyConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetWithTypeOption(t string, option *ApplyOption) (Applicant, error) {
|
func GetWithTypeOption(providerType domain.AccessProviderType, option *ApplyOption) (Applicant, error) {
|
||||||
/*
|
/*
|
||||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new constant, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
switch t {
|
switch providerType {
|
||||||
case configTypeACMEHttpReq:
|
case domain.ACCESS_PROVIDER_ACMEHTTPREQ:
|
||||||
return NewACMEHttpReqApplicant(option), nil
|
return NewACMEHttpReqApplicant(option), nil
|
||||||
case configTypeAliyun:
|
case domain.ACCESS_PROVIDER_ALIYUN:
|
||||||
return NewAliyunApplicant(option), nil
|
return NewAliyunApplicant(option), nil
|
||||||
case configTypeAWS:
|
case domain.ACCESS_PROVIDER_AWS:
|
||||||
return NewAWSApplicant(option), nil
|
return NewAWSApplicant(option), nil
|
||||||
case configTypeCloudflare:
|
case domain.ACCESS_PROVIDER_CLOUDFLARE:
|
||||||
return NewCloudflareApplicant(option), nil
|
return NewCloudflareApplicant(option), nil
|
||||||
case configTypeGoDaddy:
|
case domain.ACCESS_PROVIDER_GODADDY:
|
||||||
return NewGoDaddyApplicant(option), nil
|
return NewGoDaddyApplicant(option), nil
|
||||||
case configTypeHuaweiCloud:
|
case domain.ACCESS_PROVIDER_HUAWEICLOUD:
|
||||||
return NewHuaweiCloudApplicant(option), nil
|
return NewHuaweiCloudApplicant(option), nil
|
||||||
case configTypeNameDotCom:
|
case domain.ACCESS_PROVIDER_NAMEDOTCOM:
|
||||||
return NewNameDotComApplicant(option), nil
|
return NewNameDotComApplicant(option), nil
|
||||||
case configTypeNameSilo:
|
case domain.ACCESS_PROVIDER_NAMESILO:
|
||||||
return NewNamesiloApplicant(option), nil
|
return NewNamesiloApplicant(option), nil
|
||||||
case configTypePowerDNS:
|
case domain.ACCESS_PROVIDER_POWERDNS:
|
||||||
return NewPowerDNSApplicant(option), nil
|
return NewPowerDNSApplicant(option), nil
|
||||||
case configTypeTencentCloud:
|
case domain.ACCESS_PROVIDER_TENCENTCLOUD:
|
||||||
return NewTencentCloudApplicant(option), nil
|
return NewTencentCloudApplicant(option), nil
|
||||||
case configTypeVolcEngine:
|
case domain.ACCESS_PROVIDER_VOLCENGINE:
|
||||||
return NewVolcEngineApplicant(option), nil
|
return NewVolcEngineApplicant(option), nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported applicant type: %s", t)
|
return nil, fmt.Errorf("unsupported applicant provider type: %s", providerType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ func NewAWSApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *awsApplicant) Apply() (*Certificate, error) {
|
func (a *awsApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.AwsAccess{}
|
access := &domain.AWSAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := route53.NewDefaultConfig()
|
config := route53.NewDefaultConfig()
|
||||||
config.AccessKeyID = access.AccessKeyId
|
config.AccessKeyID = access.AccessKeyId
|
||||||
|
@ -20,8 +20,8 @@ func NewCloudflareApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *cloudflareApplicant) Apply() (*Certificate, error) {
|
func (a *cloudflareApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.CloudflareAccess{}
|
access := &domain.CloudflareAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := cloudflare.NewDefaultConfig()
|
config := cloudflare.NewDefaultConfig()
|
||||||
config.AuthToken = access.DnsApiToken
|
config.AuthToken = access.DnsApiToken
|
||||||
|
@ -20,8 +20,8 @@ func NewGoDaddyApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *godaddyApplicant) Apply() (*Certificate, error) {
|
func (a *godaddyApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.GodaddyAccess{}
|
access := &domain.GoDaddyAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := godaddy.NewDefaultConfig()
|
config := godaddy.NewDefaultConfig()
|
||||||
config.APIKey = access.ApiKey
|
config.APIKey = access.ApiKey
|
||||||
|
@ -20,8 +20,8 @@ func NewHuaweiCloudApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *huaweicloudApplicant) Apply() (*Certificate, error) {
|
func (a *huaweicloudApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.HuaweiCloudAccess{}
|
access := &domain.HuaweiCloudAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
region := access.Region
|
region := access.Region
|
||||||
if region == "" {
|
if region == "" {
|
||||||
|
@ -19,8 +19,8 @@ func NewNameDotComApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *nameDotComApplicant) Apply() (*Certificate, error) {
|
func (a *nameDotComApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.NameDotComAccess{}
|
access := &domain.NameDotComAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := namedotcom.NewDefaultConfig()
|
config := namedotcom.NewDefaultConfig()
|
||||||
config.Username = access.Username
|
config.Username = access.Username
|
||||||
|
@ -20,8 +20,8 @@ func NewNamesiloApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *namesiloApplicant) Apply() (*Certificate, error) {
|
func (a *namesiloApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.NameSiloAccess{}
|
access := &domain.NameSiloAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := namesilo.NewDefaultConfig()
|
config := namesilo.NewDefaultConfig()
|
||||||
config.APIKey = access.ApiKey
|
config.APIKey = access.ApiKey
|
||||||
|
@ -21,8 +21,8 @@ func NewPowerDNSApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *powerdnsApplicant) Apply() (*Certificate, error) {
|
func (a *powerdnsApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.PdnsAccess{}
|
access := &domain.PowerDNSAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := pdns.NewDefaultConfig()
|
config := pdns.NewDefaultConfig()
|
||||||
host, _ := url.Parse(access.ApiUrl)
|
host, _ := url.Parse(access.ApiUrl)
|
||||||
|
@ -20,8 +20,8 @@ func NewTencentCloudApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *tencentcloudApplicant) Apply() (*Certificate, error) {
|
func (a *tencentcloudApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.TencentAccess{}
|
access := &domain.TencentCloudAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := tencentcloud.NewDefaultConfig()
|
config := tencentcloud.NewDefaultConfig()
|
||||||
config.SecretID = access.SecretId
|
config.SecretID = access.SecretId
|
||||||
|
@ -19,8 +19,8 @@ func NewVolcEngineApplicant(option *ApplyOption) Applicant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *volcengineApplicant) Apply() (*Certificate, error) {
|
func (a *volcengineApplicant) Apply() (*Certificate, error) {
|
||||||
access := &domain.VolcEngineAccess{}
|
access := &domain.VolcEngineAccessConfig{}
|
||||||
json.Unmarshal([]byte(a.option.Access), access)
|
json.Unmarshal([]byte(a.option.AccessConfig), access)
|
||||||
|
|
||||||
config := volcengine.NewDefaultConfig()
|
config := volcengine.NewDefaultConfig()
|
||||||
config.AccessKey = access.AccessKeyId
|
config.AccessKey = access.AccessKeyId
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
提供商部署目标常量值。
|
提供商部署目标常量值。
|
||||||
|
短横线前的部分始终等于提供商类型。
|
||||||
|
|
||||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new constant, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
@ -140,7 +141,7 @@ type proxyDeployer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *proxyDeployer) GetID() string {
|
func (d *proxyDeployer) GetID() string {
|
||||||
return fmt.Sprintf("%s-%s", d.option.AccessRecord.GetString("name"), d.option.AccessRecord.Id)
|
return fmt.Sprintf("%s-%s", d.option.AccessRecord.Name, d.option.AccessRecord.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *proxyDeployer) GetInfos() []string {
|
func (d *proxyDeployer) GetInfos() []string {
|
||||||
|
@ -43,7 +43,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
switch target {
|
switch target {
|
||||||
case targetAliyunALB, targetAliyunCDN, targetAliyunCLB, targetAliyunDCDN, targetAliyunNLB, targetAliyunOSS:
|
case targetAliyunALB, targetAliyunCDN, targetAliyunCLB, targetAliyunDCDN, targetAliyunNLB, targetAliyunOSS:
|
||||||
{
|
{
|
||||||
access := &domain.AliyunAccess{}
|
access := &domain.AliyunAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetBaiduCloudCDN:
|
case targetBaiduCloudCDN:
|
||||||
{
|
{
|
||||||
access := &domain.BaiduCloudAccess{}
|
access := &domain.BaiduCloudAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetBytePlusCDN:
|
case targetBytePlusCDN:
|
||||||
{
|
{
|
||||||
access := &domain.ByteplusAccess{}
|
access := &domain.BytePlusAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetDogeCloudCDN:
|
case targetDogeCloudCDN:
|
||||||
{
|
{
|
||||||
access := &domain.DogeCloudAccess{}
|
access := &domain.DogeCloudAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetHuaweiCloudCDN, targetHuaweiCloudELB:
|
case targetHuaweiCloudCDN, targetHuaweiCloudELB:
|
||||||
{
|
{
|
||||||
access := &domain.HuaweiCloudAccess{}
|
access := &domain.HuaweiCloudAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetK8sSecret:
|
case targetK8sSecret:
|
||||||
{
|
{
|
||||||
access := &domain.KubernetesAccess{}
|
access := &domain.KubernetesAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetQiniuCDN:
|
case targetQiniuCDN:
|
||||||
{
|
{
|
||||||
access := &domain.QiniuAccess{}
|
access := &domain.QiniuAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetSSH:
|
case targetSSH:
|
||||||
{
|
{
|
||||||
access := &domain.SSHAccess{}
|
access := &domain.SSHAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetTencentCloudCDN, targetTencentCloudCLB, targetTencentCloudCOS, targetTencentCloudECDN, targetTencentCloudEO:
|
case targetTencentCloudCDN, targetTencentCloudCLB, targetTencentCloudCOS, targetTencentCloudECDN, targetTencentCloudEO:
|
||||||
{
|
{
|
||||||
access := &domain.TencentAccess{}
|
access := &domain.TencentCloudAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetVolcEngineCDN, targetVolcEngineLive:
|
case targetVolcEngineCDN, targetVolcEngineLive:
|
||||||
{
|
{
|
||||||
access := &domain.VolcEngineAccess{}
|
access := &domain.VolcEngineAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
@ -339,16 +339,16 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
switch target {
|
switch target {
|
||||||
case targetVolcEngineCDN:
|
case targetVolcEngineCDN:
|
||||||
deployer, err := providerVolcEngineCDN.NewWithLogger(&providerVolcEngineCDN.VolcEngineCDNDeployerConfig{
|
deployer, err := providerVolcEngineCDN.NewWithLogger(&providerVolcEngineCDN.VolcEngineCDNDeployerConfig{
|
||||||
AccessKey: access.AccessKey,
|
AccessKey: access.AccessKeyId,
|
||||||
SecretKey: access.SecretKey,
|
SecretKey: access.SecretAccessKey,
|
||||||
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
}, logger)
|
}, logger)
|
||||||
return deployer, logger, err
|
return deployer, logger, err
|
||||||
|
|
||||||
case targetVolcEngineLive:
|
case targetVolcEngineLive:
|
||||||
deployer, err := providerVolcEngineLive.NewWithLogger(&providerVolcEngineLive.VolcEngineLiveDeployerConfig{
|
deployer, err := providerVolcEngineLive.NewWithLogger(&providerVolcEngineLive.VolcEngineLiveDeployerConfig{
|
||||||
AccessKey: access.AccessKey,
|
AccessKey: access.AccessKeyId,
|
||||||
SecretKey: access.SecretKey,
|
SecretKey: access.SecretAccessKey,
|
||||||
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
Domain: maps.GetValueAsString(deployConfig, "domain"),
|
||||||
}, logger)
|
}, logger)
|
||||||
return deployer, logger, err
|
return deployer, logger, err
|
||||||
@ -360,7 +360,7 @@ func createDeployer(target string, accessConfig string, deployConfig map[string]
|
|||||||
|
|
||||||
case targetWebhook:
|
case targetWebhook:
|
||||||
{
|
{
|
||||||
access := &domain.WebhookAccess{}
|
access := &domain.WebhookAccessConfig{}
|
||||||
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
if err := json.Unmarshal([]byte(accessConfig), access); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
return nil, nil, fmt.Errorf("failed to unmarshal access config: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -4,109 +4,118 @@ import "time"
|
|||||||
|
|
||||||
type Access struct {
|
type Access struct {
|
||||||
Meta
|
Meta
|
||||||
Name string `json:"name"`
|
Name string `json:"name" db:"name"`
|
||||||
Config string `json:"config"`
|
ConfigType string `json:"configType" db:"configType"`
|
||||||
ConfigType string `json:"configType"`
|
Config string `json:"config" db:"config"`
|
||||||
Deleted time.Time `json:"deleted"`
|
Usage string `json:"usage" db:"usage"`
|
||||||
Usage string `json:"usage"`
|
DeletedAt time.Time `json:"deleted" db:"deleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兼容一下原 pocketbase 的 record
|
type AccessProviderType string
|
||||||
func (a *Access) GetString(key string) string {
|
|
||||||
switch key {
|
|
||||||
case "name":
|
|
||||||
return a.Name
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AliyunAccess struct {
|
/*
|
||||||
AccessKeyId string `json:"accessKeyId"`
|
提供商类型常量值。
|
||||||
AccessKeySecret string `json:"accessKeySecret"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ByteplusAccess struct {
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
AccessKey string `json:"accessKey"`
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
SecretKey string `json:"secretKey"`
|
*/
|
||||||
}
|
const (
|
||||||
|
ACCESS_PROVIDER_ACMEHTTPREQ = AccessProviderType("acmehttpreq")
|
||||||
|
ACCESS_PROVIDER_ALIYUN = AccessProviderType("aliyun")
|
||||||
|
ACCESS_PROVIDER_AWS = AccessProviderType("aws")
|
||||||
|
ACCESS_PROVIDER_BAIDUCLOUD = AccessProviderType("baiducloud")
|
||||||
|
ACCESS_PROVIDER_BYTEPLUS = AccessProviderType("byteplus")
|
||||||
|
ACCESS_PROVIDER_CLOUDFLARE = AccessProviderType("cloudflare")
|
||||||
|
ACCESS_PROVIDER_DOGECLOUD = AccessProviderType("dogecloud")
|
||||||
|
ACCESS_PROVIDER_GODADDY = AccessProviderType("godaddy")
|
||||||
|
ACCESS_PROVIDER_HUAWEICLOUD = AccessProviderType("huaweicloud")
|
||||||
|
ACCESS_PROVIDER_KUBERNETES = AccessProviderType("k8s")
|
||||||
|
ACCESS_PROVIDER_LOCAL = AccessProviderType("local")
|
||||||
|
ACCESS_PROVIDER_NAMEDOTCOM = AccessProviderType("namedotcom")
|
||||||
|
ACCESS_PROVIDER_NAMESILO = AccessProviderType("namesilo")
|
||||||
|
ACCESS_PROVIDER_POWERDNS = AccessProviderType("powerdns")
|
||||||
|
ACCESS_PROVIDER_QINIU = AccessProviderType("qiniu")
|
||||||
|
ACCESS_PROVIDER_SSH = AccessProviderType("ssh")
|
||||||
|
ACCESS_PROVIDER_TENCENTCLOUD = AccessProviderType("tencentcloud")
|
||||||
|
ACCESS_PROVIDER_VOLCENGINE = AccessProviderType("volcengine")
|
||||||
|
ACCESS_PROVIDER_WEBHOOK = AccessProviderType("webhook")
|
||||||
|
)
|
||||||
|
|
||||||
type TencentAccess struct {
|
type ACMEHttpReqAccessConfig struct {
|
||||||
SecretId string `json:"secretId"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HuaweiCloudAccess struct {
|
|
||||||
AccessKeyId string `json:"accessKeyId"`
|
|
||||||
SecretAccessKey string `json:"secretAccessKey"`
|
|
||||||
Region string `json:"region"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BaiduCloudAccess struct {
|
|
||||||
AccessKeyId string `json:"accessKeyId"`
|
|
||||||
SecretAccessKey string `json:"secretAccessKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AwsAccess struct {
|
|
||||||
AccessKeyId string `json:"accessKeyId"`
|
|
||||||
SecretAccessKey string `json:"secretAccessKey"`
|
|
||||||
Region string `json:"region"`
|
|
||||||
HostedZoneId string `json:"hostedZoneId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CloudflareAccess struct {
|
|
||||||
DnsApiToken string `json:"dnsApiToken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type QiniuAccess struct {
|
|
||||||
AccessKey string `json:"accessKey"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DogeCloudAccess struct {
|
|
||||||
AccessKey string `json:"accessKey"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NameSiloAccess struct {
|
|
||||||
ApiKey string `json:"apiKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GodaddyAccess struct {
|
|
||||||
ApiKey string `json:"apiKey"`
|
|
||||||
ApiSecret string `json:"apiSecret"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NameDotComAccess struct {
|
|
||||||
Username string `json:"username"`
|
|
||||||
ApiToken string `json:"apiToken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PdnsAccess struct {
|
|
||||||
ApiUrl string `json:"apiUrl"`
|
|
||||||
ApiKey string `json:"apiKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type VolcEngineAccess struct {
|
|
||||||
AccessKey string `json:"accessKey"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
|
|
||||||
// Deprecated: Use [AccessKey] and [SecretKey] instead in the future
|
|
||||||
AccessKeyId string `json:"accessKeyId"`
|
|
||||||
// Deprecated: Use [AccessKey] and [SecretKey] instead in the future
|
|
||||||
SecretAccessKey string `json:"secretAccessKey"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HttpreqAccess struct {
|
|
||||||
Endpoint string `json:"endpoint"`
|
Endpoint string `json:"endpoint"`
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LocalAccess struct{}
|
type AliyunAccessConfig struct {
|
||||||
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
AccessKeySecret string `json:"accessKeySecret"`
|
||||||
|
}
|
||||||
|
|
||||||
type SSHAccess struct {
|
type AWSAccessConfig struct {
|
||||||
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
HostedZoneId string `json:"hostedZoneId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaiduCloudAccessConfig struct {
|
||||||
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BytePlusAccessConfig struct {
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
SecretKey string `json:"secretKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CloudflareAccessConfig struct {
|
||||||
|
DnsApiToken string `json:"dnsApiToken"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DogeCloudAccessConfig struct {
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
SecretKey string `json:"secretKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GoDaddyAccessConfig struct {
|
||||||
|
ApiKey string `json:"apiKey"`
|
||||||
|
ApiSecret string `json:"apiSecret"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HuaweiCloudAccessConfig struct {
|
||||||
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LocalAccessConfig struct{}
|
||||||
|
|
||||||
|
type KubernetesAccessConfig struct {
|
||||||
|
KubeConfig string `json:"kubeConfig"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NameDotComAccessConfig struct {
|
||||||
|
Username string `json:"username"`
|
||||||
|
ApiToken string `json:"apiToken"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NameSiloAccessConfig struct {
|
||||||
|
ApiKey string `json:"apiKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PowerDNSAccessConfig struct {
|
||||||
|
ApiUrl string `json:"apiUrl"`
|
||||||
|
ApiKey string `json:"apiKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type QiniuAccessConfig struct {
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
SecretKey string `json:"secretKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SSHAccessConfig struct {
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Port string `json:"port"`
|
Port string `json:"port"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
@ -115,10 +124,16 @@ type SSHAccess struct {
|
|||||||
KeyPassphrase string `json:"keyPassphrase"`
|
KeyPassphrase string `json:"keyPassphrase"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebhookAccess struct {
|
type TencentCloudAccessConfig struct {
|
||||||
Url string `json:"url"`
|
SecretId string `json:"secretId"`
|
||||||
|
SecretKey string `json:"secretKey"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type KubernetesAccess struct {
|
type VolcEngineAccessConfig struct {
|
||||||
KubeConfig string `json:"kubeConfig"`
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WebhookAccessConfig struct {
|
||||||
|
Url string `json:"url"`
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/go-acme/lego/v4/registration"
|
"github.com/go-acme/lego/v4/registration"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AcmeAccount struct {
|
type AcmeAccount struct {
|
||||||
Id string
|
Meta
|
||||||
Ca string
|
CA string `json:"ca" db:"ca"`
|
||||||
Email string
|
Email string `json:"email" db:"email"`
|
||||||
Resource *registration.Resource
|
Resource *registration.Resource `json:"resource" db:"resource"`
|
||||||
Key string
|
Key string `json:"key" db:"key"`
|
||||||
Created time.Time
|
|
||||||
Updated time.Time
|
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ type Certificate struct {
|
|||||||
IssuerCertificate string `json:"issuerCertificate" db:"issuerCertificate"`
|
IssuerCertificate string `json:"issuerCertificate" db:"issuerCertificate"`
|
||||||
CertUrl string `json:"certUrl" db:"certUrl"`
|
CertUrl string `json:"certUrl" db:"certUrl"`
|
||||||
CertStableUrl string `json:"certStableUrl" db:"certStableUrl"`
|
CertStableUrl string `json:"certStableUrl" db:"certStableUrl"`
|
||||||
Output string `json:"output" db:"output"`
|
WorkflowId string `json:"workflow" db:"workflow"`
|
||||||
Workflow string `json:"workflow" db:"workflow"`
|
WorkflowNodeId string `json:"nodeId" db:"nodeId"`
|
||||||
ExpireAt time.Time `json:"ExpireAt" db:"expireAt"`
|
WorkflowOutputId string `json:"output" db:"output"`
|
||||||
NodeId string `json:"nodeId" db:"nodeId"`
|
ExpireAt time.Time `json:"expireAt" db:"expireAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetaData struct {
|
type CertificateMeta struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
SerialNumber string `json:"serialNumber"`
|
SerialNumber string `json:"serialNumber"`
|
||||||
Validity CertificateValidity `json:"validity"`
|
Validity CertificateValidity `json:"validity"`
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type Meta struct {
|
|
||||||
Id string `json:"id" db:"id"`
|
|
||||||
Created time.Time `json:"created" db:"created"`
|
|
||||||
Updated time.Time `json:"updated" db:"updated"`
|
|
||||||
}
|
|
@ -1,12 +1,6 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import (
|
// Deprecated: TODO: 即将废弃
|
||||||
"encoding/json"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ApplyConfig struct {
|
type ApplyConfig struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Access string `json:"access"`
|
Access string `json:"access"`
|
||||||
@ -16,6 +10,7 @@ type ApplyConfig struct {
|
|||||||
DisableFollowCNAME bool `json:"disableFollowCNAME"`
|
DisableFollowCNAME bool `json:"disableFollowCNAME"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: TODO: 即将废弃
|
||||||
type DeployConfig struct {
|
type DeployConfig struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Access string `json:"access"`
|
Access string `json:"access"`
|
||||||
@ -23,121 +18,7 @@ type DeployConfig struct {
|
|||||||
Config map[string]any `json:"config"`
|
Config map[string]any `json:"config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: 以字符串形式获取配置项。
|
// Deprecated: TODO: 即将废弃
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在或者类型不是字符串,则返回空字符串。
|
|
||||||
func (dc *DeployConfig) GetConfigAsString(key string) string {
|
|
||||||
return maps.GetValueAsString(dc.Config, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以字符串形式获取配置项。
|
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
// - defaultValue: 默认值。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在、类型不是字符串或者值为零值,则返回默认值。
|
|
||||||
func (dc *DeployConfig) GetConfigOrDefaultAsString(key string, defaultValue string) string {
|
|
||||||
return maps.GetValueOrDefaultAsString(dc.Config, key, defaultValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以 32 位整数形式获取配置项。
|
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在或者类型不是 32 位整数,则返回 0。
|
|
||||||
func (dc *DeployConfig) GetConfigAsInt32(key string) int32 {
|
|
||||||
return maps.GetValueAsInt32(dc.Config, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以 32 位整数形式获取配置项。
|
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
// - defaultValue: 默认值。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在、类型不是 32 位整数或者值为零值,则返回默认值。
|
|
||||||
func (dc *DeployConfig) GetConfigOrDefaultAsInt32(key string, defaultValue int32) int32 {
|
|
||||||
return maps.GetValueOrDefaultAsInt32(dc.Config, key, defaultValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以布尔形式获取配置项。
|
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在或者类型不是布尔,则返回 false。
|
|
||||||
func (dc *DeployConfig) GetConfigAsBool(key string) bool {
|
|
||||||
return maps.GetValueAsBool(dc.Config, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以布尔形式获取配置项。
|
|
||||||
//
|
|
||||||
// 入参:
|
|
||||||
// - key: 配置项的键。
|
|
||||||
// - defaultValue: 默认值。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 配置项的值。如果配置项不存在或者类型不是布尔,则返回默认值。
|
|
||||||
func (dc *DeployConfig) GetConfigOrDefaultAsBool(key string, defaultValue bool) bool {
|
|
||||||
return maps.GetValueOrDefaultAsBool(dc.Config, key, defaultValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: 以变量字典形式获取配置项。
|
|
||||||
//
|
|
||||||
// 出参:
|
|
||||||
// - 变量字典。
|
|
||||||
func (dc *DeployConfig) GetConfigAsVariables() map[string]string {
|
|
||||||
rs := make(map[string]string)
|
|
||||||
|
|
||||||
if dc.Config != nil {
|
|
||||||
value, ok := dc.Config["variables"]
|
|
||||||
if !ok {
|
|
||||||
return rs
|
|
||||||
}
|
|
||||||
|
|
||||||
kvs := make([]KV, 0)
|
|
||||||
bts, _ := json.Marshal(value)
|
|
||||||
if err := json.Unmarshal(bts, &kvs); err != nil {
|
|
||||||
return rs
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, kv := range kvs {
|
|
||||||
rs[kv.Key] = kv.Value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rs
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: GetDomain returns the domain from the deploy config,
|
|
||||||
// if the domain is a wildcard domain, and wildcard is true, return the wildcard domain
|
|
||||||
func (dc *DeployConfig) GetDomain(wildcard ...bool) string {
|
|
||||||
val := dc.GetConfigAsString("domain")
|
|
||||||
if val == "" {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.HasPrefix(val, "*") {
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(wildcard) > 0 && wildcard[0] {
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.TrimPrefix(val, "*")
|
|
||||||
}
|
|
||||||
|
|
||||||
type KV struct {
|
type KV struct {
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
|
9
internal/domain/meta.go
Normal file
9
internal/domain/meta.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Meta struct {
|
||||||
|
Id string `json:"id" db:"id"`
|
||||||
|
CreatedAt time.Time `json:"created" db:"created"`
|
||||||
|
UpdatedAt time.Time `json:"updated" db:"updated"`
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
|
type NotifyChannelType string
|
||||||
|
|
||||||
/*
|
/*
|
||||||
消息通知渠道常量值。
|
消息通知渠道常量值。
|
||||||
|
|
||||||
@ -7,14 +9,14 @@ package domain
|
|||||||
NOTICE: If you add new constant, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
const (
|
const (
|
||||||
NotifyChannelBark = "bark"
|
NOTIFY_CHANNEL_BARK = NotifyChannelType("bark")
|
||||||
NotifyChannelDingtalk = "dingtalk"
|
NOTIFY_CHANNEL_DINGTALK = NotifyChannelType("dingtalk")
|
||||||
NotifyChannelEmail = "email"
|
NOTIFY_CHANNEL_EMAIL = NotifyChannelType("email")
|
||||||
NotifyChannelLark = "lark"
|
NOTIFY_CHANNEL_LARK = NotifyChannelType("lark")
|
||||||
NotifyChannelServerChan = "serverchan"
|
NOTIFY_CHANNEL_SERVERCHAN = NotifyChannelType("serverchan")
|
||||||
NotifyChannelTelegram = "telegram"
|
NOTIFY_CHANNEL_TELEGRAM = NotifyChannelType("telegram")
|
||||||
NotifyChannelWebhook = "webhook"
|
NOTIFY_CHANNEL_WEBHOOK = NotifyChannelType("webhook")
|
||||||
NotifyChannelWeCom = "wecom"
|
NOTIFY_CHANNEL_WECOM = NotifyChannelType("wecom")
|
||||||
)
|
)
|
||||||
|
|
||||||
type NotifyTestPushReq struct {
|
type NotifyTestPushReq struct {
|
||||||
|
@ -3,21 +3,18 @@ package domain
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Setting struct {
|
type Settings struct {
|
||||||
ID string `json:"id"`
|
Meta
|
||||||
Name string `json:"name"`
|
Name string `json:"name" db:"name"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content" db:"content"`
|
||||||
Created time.Time `json:"created"`
|
|
||||||
Updated time.Time `json:"updated"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelsConfig map[string]map[string]any
|
type NotifyChannelsConfig map[string]map[string]any
|
||||||
|
|
||||||
func (s *Setting) GetChannelContent(channel string) (map[string]any, error) {
|
func (s *Settings) GetChannelContent(channel string) (map[string]any, error) {
|
||||||
conf := &ChannelsConfig{}
|
conf := &NotifyChannelsConfig{}
|
||||||
if err := json.Unmarshal([]byte(s.Content), conf); err != nil {
|
if err := json.Unmarshal([]byte(s.Content), conf); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -16,25 +16,25 @@ import (
|
|||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createNotifier(channel string, channelConfig map[string]any) (notifier.Notifier, error) {
|
func createNotifier(channel domain.NotifyChannelType, channelConfig map[string]any) (notifier.Notifier, error) {
|
||||||
/*
|
/*
|
||||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new constant, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
switch channel {
|
switch channel {
|
||||||
case domain.NotifyChannelBark:
|
case domain.NOTIFY_CHANNEL_BARK:
|
||||||
return providerBark.New(&providerBark.BarkNotifierConfig{
|
return providerBark.New(&providerBark.BarkNotifierConfig{
|
||||||
DeviceKey: maps.GetValueAsString(channelConfig, "deviceKey"),
|
DeviceKey: maps.GetValueAsString(channelConfig, "deviceKey"),
|
||||||
ServerUrl: maps.GetValueAsString(channelConfig, "serverUrl"),
|
ServerUrl: maps.GetValueAsString(channelConfig, "serverUrl"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelDingtalk:
|
case domain.NOTIFY_CHANNEL_DINGTALK:
|
||||||
return providerDingTalk.New(&providerDingTalk.DingTalkNotifierConfig{
|
return providerDingTalk.New(&providerDingTalk.DingTalkNotifierConfig{
|
||||||
AccessToken: maps.GetValueAsString(channelConfig, "accessToken"),
|
AccessToken: maps.GetValueAsString(channelConfig, "accessToken"),
|
||||||
Secret: maps.GetValueAsString(channelConfig, "secret"),
|
Secret: maps.GetValueAsString(channelConfig, "secret"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelEmail:
|
case domain.NOTIFY_CHANNEL_EMAIL:
|
||||||
return providerEmail.New(&providerEmail.EmailNotifierConfig{
|
return providerEmail.New(&providerEmail.EmailNotifierConfig{
|
||||||
SmtpHost: maps.GetValueAsString(channelConfig, "smtpHost"),
|
SmtpHost: maps.GetValueAsString(channelConfig, "smtpHost"),
|
||||||
SmtpPort: maps.GetValueAsInt32(channelConfig, "smtpPort"),
|
SmtpPort: maps.GetValueAsInt32(channelConfig, "smtpPort"),
|
||||||
@ -45,28 +45,28 @@ func createNotifier(channel string, channelConfig map[string]any) (notifier.Noti
|
|||||||
ReceiverAddress: maps.GetValueAsString(channelConfig, "receiverAddress"),
|
ReceiverAddress: maps.GetValueAsString(channelConfig, "receiverAddress"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelLark:
|
case domain.NOTIFY_CHANNEL_LARK:
|
||||||
return providerLark.New(&providerLark.LarkNotifierConfig{
|
return providerLark.New(&providerLark.LarkNotifierConfig{
|
||||||
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelServerChan:
|
case domain.NOTIFY_CHANNEL_SERVERCHAN:
|
||||||
return providerServerChan.New(&providerServerChan.ServerChanNotifierConfig{
|
return providerServerChan.New(&providerServerChan.ServerChanNotifierConfig{
|
||||||
Url: maps.GetValueAsString(channelConfig, "url"),
|
Url: maps.GetValueAsString(channelConfig, "url"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelTelegram:
|
case domain.NOTIFY_CHANNEL_TELEGRAM:
|
||||||
return providerTelegram.New(&providerTelegram.TelegramNotifierConfig{
|
return providerTelegram.New(&providerTelegram.TelegramNotifierConfig{
|
||||||
ApiToken: maps.GetValueAsString(channelConfig, "apiToken"),
|
ApiToken: maps.GetValueAsString(channelConfig, "apiToken"),
|
||||||
ChatId: maps.GetValueAsInt64(channelConfig, "chatId"),
|
ChatId: maps.GetValueAsInt64(channelConfig, "chatId"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelWebhook:
|
case domain.NOTIFY_CHANNEL_WEBHOOK:
|
||||||
return providerWebhook.New(&providerWebhook.WebhookNotifierConfig{
|
return providerWebhook.New(&providerWebhook.WebhookNotifierConfig{
|
||||||
Url: maps.GetValueAsString(channelConfig, "url"),
|
Url: maps.GetValueAsString(channelConfig, "url"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelWeCom:
|
case domain.NOTIFY_CHANNEL_WECOM:
|
||||||
return providerWeCom.New(&providerWeCom.WeComNotifierConfig{
|
return providerWeCom.New(&providerWeCom.WeComNotifierConfig{
|
||||||
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/usual2970/certimate/internal/app"
|
"github.com/usual2970/certimate/internal/app"
|
||||||
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
"github.com/usual2970/certimate/internal/pkg/core/notifier"
|
"github.com/usual2970/certimate/internal/pkg/core/notifier"
|
||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||||
)
|
)
|
||||||
@ -37,7 +38,7 @@ func SendToAllChannels(subject, message string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SendToChannel(subject, message string, channel string, channelConfig map[string]any) error {
|
func SendToChannel(subject, message string, channel string, channelConfig map[string]any) error {
|
||||||
notifier, err := createNotifier(channel, channelConfig)
|
notifier, err := createNotifier(domain.NotifyChannelType(channel), channelConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ func getEnabledNotifiers() ([]notifier.Notifier, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier, err := createNotifier(k, v)
|
notifier, err := createNotifier(domain.NotifyChannelType(k), v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SettingRepository interface {
|
type SettingRepository interface {
|
||||||
GetByName(ctx context.Context, name string) (*domain.Setting, error)
|
GetByName(ctx context.Context, name string) (*domain.Settings, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotifyService struct {
|
type NotifyService struct {
|
||||||
|
@ -27,8 +27,8 @@ func (a *AccessRepository) GetById(ctx context.Context, id string) (*domain.Acce
|
|||||||
rs := &domain.Access{
|
rs := &domain.Access{
|
||||||
Meta: domain.Meta{
|
Meta: domain.Meta{
|
||||||
Id: record.GetId(),
|
Id: record.GetId(),
|
||||||
Created: record.GetTime("created"),
|
CreatedAt: record.GetTime("created"),
|
||||||
Updated: record.GetTime("updated"),
|
UpdatedAt: record.GetTime("updated"),
|
||||||
},
|
},
|
||||||
Name: record.GetString("name"),
|
Name: record.GetString("name"),
|
||||||
Config: record.GetString("config"),
|
Config: record.GetString("config"),
|
||||||
|
@ -47,13 +47,15 @@ func (r *AcmeAccountRepository) GetByCAAndEmail(ca, email string) (*domain.AcmeA
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &domain.AcmeAccount{
|
return &domain.AcmeAccount{
|
||||||
|
Meta: domain.Meta{
|
||||||
Id: record.GetString("id"),
|
Id: record.GetString("id"),
|
||||||
Ca: record.GetString("ca"),
|
CreatedAt: record.GetTime("created"),
|
||||||
|
UpdatedAt: record.GetTime("updated"),
|
||||||
|
},
|
||||||
|
CA: record.GetString("ca"),
|
||||||
Email: record.GetString("email"),
|
Email: record.GetString("email"),
|
||||||
Key: record.GetString("key"),
|
Key: record.GetString("key"),
|
||||||
Resource: resource,
|
Resource: resource,
|
||||||
Created: record.GetTime("created"),
|
|
||||||
Updated: record.GetTime("updated"),
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/pocketbase/dbx"
|
||||||
"github.com/usual2970/certimate/internal/app"
|
"github.com/usual2970/certimate/internal/app"
|
||||||
"github.com/usual2970/certimate/internal/domain"
|
"github.com/usual2970/certimate/internal/domain"
|
||||||
)
|
)
|
||||||
@ -13,18 +14,20 @@ func NewSettingRepository() *SettingRepository {
|
|||||||
return &SettingRepository{}
|
return &SettingRepository{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SettingRepository) GetByName(ctx context.Context, name string) (*domain.Setting, error) {
|
func (s *SettingRepository) GetByName(ctx context.Context, name string) (*domain.Settings, error) {
|
||||||
resp, err := app.GetApp().Dao().FindFirstRecordByFilter("settings", "name='"+name+"'")
|
resp, err := app.GetApp().Dao().FindFirstRecordByFilter("settings", "name={:name}", dbx.Params{"name": name})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rs := &domain.Setting{
|
rs := &domain.Settings{
|
||||||
ID: resp.GetString("id"),
|
Meta: domain.Meta{
|
||||||
|
Id: resp.GetString("id"),
|
||||||
|
CreatedAt: resp.GetTime("created"),
|
||||||
|
UpdatedAt: resp.GetTime("updated"),
|
||||||
|
},
|
||||||
Name: resp.GetString("name"),
|
Name: resp.GetString("name"),
|
||||||
Content: resp.GetString("content"),
|
Content: resp.GetString("content"),
|
||||||
Created: resp.GetTime("created"),
|
|
||||||
Updated: resp.GetTime("updated"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rs, nil
|
return rs, nil
|
||||||
|
@ -78,8 +78,8 @@ func record2Workflow(record *models.Record) (*domain.Workflow, error) {
|
|||||||
workflow := &domain.Workflow{
|
workflow := &domain.Workflow{
|
||||||
Meta: domain.Meta{
|
Meta: domain.Meta{
|
||||||
Id: record.GetId(),
|
Id: record.GetId(),
|
||||||
Created: record.GetTime("created"),
|
CreatedAt: record.GetTime("created"),
|
||||||
Updated: record.GetTime("updated"),
|
UpdatedAt: record.GetTime("updated"),
|
||||||
},
|
},
|
||||||
Name: record.GetString("name"),
|
Name: record.GetString("name"),
|
||||||
Description: record.GetString("description"),
|
Description: record.GetString("description"),
|
||||||
|
@ -43,8 +43,8 @@ func (w *WorkflowOutputRepository) Get(ctx context.Context, nodeId string) (*dom
|
|||||||
rs := &domain.WorkflowOutput{
|
rs := &domain.WorkflowOutput{
|
||||||
Meta: domain.Meta{
|
Meta: domain.Meta{
|
||||||
Id: record.GetId(),
|
Id: record.GetId(),
|
||||||
Created: record.GetCreated().Time(),
|
CreatedAt: record.GetCreated().Time(),
|
||||||
Updated: record.GetUpdated().Time(),
|
UpdatedAt: record.GetUpdated().Time(),
|
||||||
},
|
},
|
||||||
Workflow: record.GetString("workflow"),
|
Workflow: record.GetString("workflow"),
|
||||||
NodeId: record.GetString("nodeId"),
|
NodeId: record.GetString("nodeId"),
|
||||||
@ -73,19 +73,19 @@ func (w *WorkflowOutputRepository) GetCertificate(ctx context.Context, nodeId st
|
|||||||
rs := &domain.Certificate{
|
rs := &domain.Certificate{
|
||||||
Meta: domain.Meta{
|
Meta: domain.Meta{
|
||||||
Id: record.GetId(),
|
Id: record.GetId(),
|
||||||
Created: record.GetDateTime("created").Time(),
|
CreatedAt: record.GetDateTime("created").Time(),
|
||||||
Updated: record.GetDateTime("updated").Time(),
|
UpdatedAt: record.GetDateTime("updated").Time(),
|
||||||
},
|
},
|
||||||
Certificate: record.GetString("certificate"),
|
Certificate: record.GetString("certificate"),
|
||||||
PrivateKey: record.GetString("privateKey"),
|
PrivateKey: record.GetString("privateKey"),
|
||||||
IssuerCertificate: record.GetString("issuerCertificate"),
|
IssuerCertificate: record.GetString("issuerCertificate"),
|
||||||
SAN: record.GetString("san"),
|
SAN: record.GetString("san"),
|
||||||
Output: record.GetString("output"),
|
WorkflowOutputId: record.GetString("output"),
|
||||||
ExpireAt: record.GetDateTime("expireAt").Time(),
|
ExpireAt: record.GetDateTime("expireAt").Time(),
|
||||||
CertUrl: record.GetString("certUrl"),
|
CertUrl: record.GetString("certUrl"),
|
||||||
CertStableUrl: record.GetString("certStableUrl"),
|
CertStableUrl: record.GetString("certStableUrl"),
|
||||||
Workflow: record.GetString("workflow"),
|
WorkflowId: record.GetString("workflow"),
|
||||||
NodeId: record.GetString("nodeId"),
|
WorkflowNodeId: record.GetString("nodeId"),
|
||||||
}
|
}
|
||||||
return rs, nil
|
return rs, nil
|
||||||
}
|
}
|
||||||
@ -132,12 +132,12 @@ func (w *WorkflowOutputRepository) Save(ctx context.Context, output *domain.Work
|
|||||||
certRecord.Set("privateKey", certificate.PrivateKey)
|
certRecord.Set("privateKey", certificate.PrivateKey)
|
||||||
certRecord.Set("issuerCertificate", certificate.IssuerCertificate)
|
certRecord.Set("issuerCertificate", certificate.IssuerCertificate)
|
||||||
certRecord.Set("san", certificate.SAN)
|
certRecord.Set("san", certificate.SAN)
|
||||||
certRecord.Set("output", certificate.Output)
|
certRecord.Set("output", certificate.WorkflowOutputId)
|
||||||
certRecord.Set("expireAt", certificate.ExpireAt)
|
certRecord.Set("expireAt", certificate.ExpireAt)
|
||||||
certRecord.Set("certUrl", certificate.CertUrl)
|
certRecord.Set("certUrl", certificate.CertUrl)
|
||||||
certRecord.Set("certStableUrl", certificate.CertStableUrl)
|
certRecord.Set("certStableUrl", certificate.CertStableUrl)
|
||||||
certRecord.Set("workflow", certificate.Workflow)
|
certRecord.Set("workflow", certificate.WorkflowId)
|
||||||
certRecord.Set("nodeId", certificate.NodeId)
|
certRecord.Set("nodeId", certificate.WorkflowNodeId)
|
||||||
|
|
||||||
if err := app.GetApp().Dao().SaveRecord(certRecord); err != nil {
|
if err := app.GetApp().Dao().SaveRecord(certRecord); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -103,13 +103,13 @@ func (a *applyNode) Run(ctx context.Context) error {
|
|||||||
CertUrl: certificate.CertUrl,
|
CertUrl: certificate.CertUrl,
|
||||||
CertStableUrl: certificate.CertStableUrl,
|
CertStableUrl: certificate.CertStableUrl,
|
||||||
ExpireAt: cert.NotAfter,
|
ExpireAt: cert.NotAfter,
|
||||||
Workflow: GetWorkflowId(ctx),
|
WorkflowId: GetWorkflowId(ctx),
|
||||||
NodeId: a.node.Id,
|
WorkflowNodeId: a.node.Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.outputRepo.Save(ctx, output, certificateRecord, func(id string) error {
|
if err := a.outputRepo.Save(ctx, output, certificateRecord, func(id string) error {
|
||||||
if certificateRecord != nil {
|
if certificateRecord != nil {
|
||||||
certificateRecord.Output = id
|
certificateRecord.WorkflowOutputId = id
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -53,7 +53,7 @@ func (d *deployNode) Run(ctx context.Context) error {
|
|||||||
// 部署过但是证书更新了,重新部署
|
// 部署过但是证书更新了,重新部署
|
||||||
// 部署过且证书未更新,直接返回
|
// 部署过且证书未更新,直接返回
|
||||||
|
|
||||||
if d.deployed(output) && cert.Created.Before(output.Updated) {
|
if d.deployed(output) && cert.CreatedAt.Before(output.UpdatedAt) {
|
||||||
d.AddOutput(ctx, d.node.Name, "已部署过且证书未更新")
|
d.AddOutput(ctx, d.node.Name, "已部署过且证书未更新")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SettingRepository interface {
|
type SettingRepository interface {
|
||||||
GetByName(ctx context.Context, name string) (*domain.Setting, error)
|
GetByName(ctx context.Context, name string) (*domain.Settings, error)
|
||||||
}
|
}
|
||||||
type notifyNode struct {
|
type notifyNode struct {
|
||||||
node *domain.WorkflowNode
|
node *domain.WorkflowNode
|
||||||
|
@ -6,7 +6,7 @@ import { createSchemaFieldRule } from "antd-zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { useAntdForm } from "@/hooks";
|
import { useAntdForm } from "@/hooks";
|
||||||
import { ACCESS_PROVIDER_TYPES, type AccessModel } from "@/domain/access";
|
import { ACCESS_PROVIDERS, type AccessModel } from "@/domain/access";
|
||||||
import AccessTypeSelect from "./AccessTypeSelect";
|
import AccessTypeSelect from "./AccessTypeSelect";
|
||||||
import AccessEditFormACMEHttpReqConfig from "./AccessEditFormACMEHttpReqConfig";
|
import AccessEditFormACMEHttpReqConfig from "./AccessEditFormACMEHttpReqConfig";
|
||||||
import AccessEditFormAliyunConfig from "./AccessEditFormAliyunConfig";
|
import AccessEditFormAliyunConfig from "./AccessEditFormAliyunConfig";
|
||||||
@ -55,7 +55,7 @@ const AccessEditForm = forwardRef<AccessEditFormInstance, AccessEditFormProps>((
|
|||||||
.trim()
|
.trim()
|
||||||
.min(1, t("access.form.name.placeholder"))
|
.min(1, t("access.form.name.placeholder"))
|
||||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||||
configType: z.nativeEnum(ACCESS_PROVIDER_TYPES, { message: t("access.form.type.placeholder") }),
|
configType: z.nativeEnum(ACCESS_PROVIDERS, { message: t("access.form.type.placeholder") }),
|
||||||
config: z.any(),
|
config: z.any(),
|
||||||
});
|
});
|
||||||
const formRule = createSchemaFieldRule(formSchema);
|
const formRule = createSchemaFieldRule(formSchema);
|
||||||
@ -77,43 +77,43 @@ const AccessEditForm = forwardRef<AccessEditFormInstance, AccessEditFormProps>((
|
|||||||
*/
|
*/
|
||||||
const configFormProps = { form: configFormInst, formName: configFormName, disabled: disabled, initialValues: initialValues?.config };
|
const configFormProps = { form: configFormInst, formName: configFormName, disabled: disabled, initialValues: initialValues?.config };
|
||||||
switch (configType) {
|
switch (configType) {
|
||||||
case ACCESS_PROVIDER_TYPES.ACMEHTTPREQ:
|
case ACCESS_PROVIDERS.ACMEHTTPREQ:
|
||||||
return <AccessEditFormACMEHttpReqConfig {...configFormProps} />;
|
return <AccessEditFormACMEHttpReqConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.ALIYUN:
|
case ACCESS_PROVIDERS.ALIYUN:
|
||||||
return <AccessEditFormAliyunConfig {...configFormProps} />;
|
return <AccessEditFormAliyunConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.AWS:
|
case ACCESS_PROVIDERS.AWS:
|
||||||
return <AccessEditFormAWSConfig {...configFormProps} />;
|
return <AccessEditFormAWSConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.BAIDUCLOUD:
|
case ACCESS_PROVIDERS.BAIDUCLOUD:
|
||||||
return <AccessEditFormBaiduCloudConfig {...configFormProps} />;
|
return <AccessEditFormBaiduCloudConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.BYTEPLUS:
|
case ACCESS_PROVIDERS.BYTEPLUS:
|
||||||
return <AccessEditFormBytePlusConfig {...configFormProps} />;
|
return <AccessEditFormBytePlusConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.CLOUDFLARE:
|
case ACCESS_PROVIDERS.CLOUDFLARE:
|
||||||
return <AccessEditFormCloudflareConfig {...configFormProps} />;
|
return <AccessEditFormCloudflareConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.DOGECLOUD:
|
case ACCESS_PROVIDERS.DOGECLOUD:
|
||||||
return <AccessEditFormDogeCloudConfig {...configFormProps} />;
|
return <AccessEditFormDogeCloudConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.GODADDY:
|
case ACCESS_PROVIDERS.GODADDY:
|
||||||
return <AccessEditFormGoDaddyConfig {...configFormProps} />;
|
return <AccessEditFormGoDaddyConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.HUAWEICLOUD:
|
case ACCESS_PROVIDERS.HUAWEICLOUD:
|
||||||
return <AccessEditFormHuaweiCloudConfig {...configFormProps} />;
|
return <AccessEditFormHuaweiCloudConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.KUBERNETES:
|
case ACCESS_PROVIDERS.KUBERNETES:
|
||||||
return <AccessEditFormKubernetesConfig {...configFormProps} />;
|
return <AccessEditFormKubernetesConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.LOCAL:
|
case ACCESS_PROVIDERS.LOCAL:
|
||||||
return <AccessEditFormLocalConfig {...configFormProps} />;
|
return <AccessEditFormLocalConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.NAMEDOTCOM:
|
case ACCESS_PROVIDERS.NAMEDOTCOM:
|
||||||
return <AccessEditFormNameDotComConfig {...configFormProps} />;
|
return <AccessEditFormNameDotComConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.NAMESILO:
|
case ACCESS_PROVIDERS.NAMESILO:
|
||||||
return <AccessEditFormNameSiloConfig {...configFormProps} />;
|
return <AccessEditFormNameSiloConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.POWERDNS:
|
case ACCESS_PROVIDERS.POWERDNS:
|
||||||
return <AccessEditFormPowerDNSConfig {...configFormProps} />;
|
return <AccessEditFormPowerDNSConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.QINIU:
|
case ACCESS_PROVIDERS.QINIU:
|
||||||
return <AccessEditFormQiniuConfig {...configFormProps} />;
|
return <AccessEditFormQiniuConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.SSH:
|
case ACCESS_PROVIDERS.SSH:
|
||||||
return <AccessEditFormSSHConfig {...configFormProps} />;
|
return <AccessEditFormSSHConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.TENCENTCLOUD:
|
case ACCESS_PROVIDERS.TENCENTCLOUD:
|
||||||
return <AccessEditFormTencentCloudConfig {...configFormProps} />;
|
return <AccessEditFormTencentCloudConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.VOLCENGINE:
|
case ACCESS_PROVIDERS.VOLCENGINE:
|
||||||
return <AccessEditFormVolcEngineConfig {...configFormProps} />;
|
return <AccessEditFormVolcEngineConfig {...configFormProps} />;
|
||||||
case ACCESS_PROVIDER_TYPES.WEBHOOK:
|
case ACCESS_PROVIDERS.WEBHOOK:
|
||||||
return <AccessEditFormWebhookConfig {...configFormProps} />;
|
return <AccessEditFormWebhookConfig {...configFormProps} />;
|
||||||
}
|
}
|
||||||
}, [disabled, initialValues, configType, configFormInst, configFormName]);
|
}, [disabled, initialValues, configType, configFormInst, configFormName]);
|
||||||
|
@ -2,7 +2,7 @@ import { memo } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Avatar, Select, Space, Tag, Typography, type SelectProps } from "antd";
|
import { Avatar, Select, Space, Tag, Typography, type SelectProps } from "antd";
|
||||||
|
|
||||||
import { ACCESS_PROVIDER_USAGES, accessProvidersMap } from "@/domain/access";
|
import { ACCESS_USAGES, accessProvidersMap } from "@/domain/access";
|
||||||
|
|
||||||
export type AccessTypeSelectProps = Omit<
|
export type AccessTypeSelectProps = Omit<
|
||||||
SelectProps,
|
SelectProps,
|
||||||
@ -29,17 +29,17 @@ const AccessTypeSelect = (props: AccessTypeSelectProps) => {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Space>
|
</Space>
|
||||||
<div>
|
<div>
|
||||||
{provider?.usage === ACCESS_PROVIDER_USAGES.APPLY && (
|
{provider?.usage === ACCESS_USAGES.APPLY && (
|
||||||
<>
|
<>
|
||||||
<Tag color="orange">{t("access.props.provider.usage.dns")}</Tag>
|
<Tag color="orange">{t("access.props.provider.usage.dns")}</Tag>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{provider?.usage === ACCESS_PROVIDER_USAGES.DEPLOY && (
|
{provider?.usage === ACCESS_USAGES.DEPLOY && (
|
||||||
<>
|
<>
|
||||||
<Tag color="blue">{t("access.props.provider.usage.host")}</Tag>
|
<Tag color="blue">{t("access.props.provider.usage.host")}</Tag>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{provider?.usage === ACCESS_PROVIDER_USAGES.ALL && (
|
{provider?.usage === ACCESS_USAGES.ALL && (
|
||||||
<>
|
<>
|
||||||
<Tag color="orange">{t("access.props.provider.usage.dns")}</Tag>
|
<Tag color="orange">{t("access.props.provider.usage.dns")}</Tag>
|
||||||
<Tag color="blue">{t("access.props.provider.usage.host")}</Tag>
|
<Tag color="blue">{t("access.props.provider.usage.host")}</Tag>
|
||||||
|
@ -67,9 +67,9 @@ const Node = ({ data }: NodeProps) => {
|
|||||||
case WorkflowNodeType.Notify: {
|
case WorkflowNodeType.Notify: {
|
||||||
const channelLabel = notifyChannelsMap.get(data.config?.channel as string);
|
const channelLabel = notifyChannelsMap.get(data.config?.channel as string);
|
||||||
return (
|
return (
|
||||||
<div className="flex space-x-2 items-baseline">
|
<div className="flex space-x-2 items-center justify-between">
|
||||||
<div className="text-stone-700 w-12 truncate">{t(channelLabel?.name ?? "")}</div>
|
<div className="text-stone-700 truncate">{t(channelLabel?.name ?? "")}</div>
|
||||||
<div className="text-muted-foreground truncate">{(data.config?.title as string) ?? ""}</div>
|
<div className="text-muted-foreground truncate">{(data.config?.subject as string) ?? ""}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import ModalForm from "@/components/core/ModalForm";
|
|||||||
import MultipleInput from "@/components/core/MultipleInput";
|
import MultipleInput from "@/components/core/MultipleInput";
|
||||||
import { usePanel } from "../PanelProvider";
|
import { usePanel } from "../PanelProvider";
|
||||||
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
import { useAntdForm, useZustandShallowSelector } from "@/hooks";
|
||||||
import { ACCESS_PROVIDER_USAGES, accessProvidersMap } from "@/domain/access";
|
import { ACCESS_USAGES, accessProvidersMap } from "@/domain/access";
|
||||||
import { type WorkflowNode, type WorkflowNodeConfig } from "@/domain/workflow";
|
import { type WorkflowNode, type WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useContactStore } from "@/stores/contact";
|
import { useContactStore } from "@/stores/contact";
|
||||||
import { useWorkflowStore } from "@/stores/workflow";
|
import { useWorkflowStore } from "@/stores/workflow";
|
||||||
@ -163,7 +163,7 @@ const ApplyNodeForm = ({ data }: ApplyNodeFormProps) => {
|
|||||||
}
|
}
|
||||||
onSubmit={(record) => {
|
onSubmit={(record) => {
|
||||||
const provider = accessProvidersMap.get(record.configType);
|
const provider = accessProvidersMap.get(record.configType);
|
||||||
if (ACCESS_PROVIDER_USAGES.ALL === provider?.usage || ACCESS_PROVIDER_USAGES.APPLY === provider?.usage) {
|
if (ACCESS_USAGES.ALL === provider?.usage || ACCESS_USAGES.APPLY === provider?.usage) {
|
||||||
formInst.setFieldValue("access", record.id);
|
formInst.setFieldValue("access", record.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -176,7 +176,7 @@ const ApplyNodeForm = ({ data }: ApplyNodeFormProps) => {
|
|||||||
placeholder={t("workflow.nodes.apply.form.access.placeholder")}
|
placeholder={t("workflow.nodes.apply.form.access.placeholder")}
|
||||||
filter={(record) => {
|
filter={(record) => {
|
||||||
const provider = accessProvidersMap.get(record.configType);
|
const provider = accessProvidersMap.get(record.configType);
|
||||||
return ACCESS_PROVIDER_USAGES.ALL === provider?.usage || ACCESS_PROVIDER_USAGES.APPLY === provider?.usage;
|
return ACCESS_USAGES.ALL === provider?.usage || ACCESS_USAGES.APPLY === provider?.usage;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -2,65 +2,65 @@
|
|||||||
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new constant, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
export const ACCESS_PROVIDER_TYPE_ACMEHTTPREQ = "acmehttpreq" as const;
|
export const ACCESS_PROVIDER_ACMEHTTPREQ = "acmehttpreq" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_ALIYUN = "aliyun" as const;
|
export const ACCESS_PROVIDER_ALIYUN = "aliyun" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_AWS = "aws" as const;
|
export const ACCESS_PROVIDER_AWS = "aws" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_BAIDUCLOUD = "baiducloud" as const;
|
export const ACCESS_PROVIDER_BAIDUCLOUD = "baiducloud" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_BYTEPLUS = "byteplus" as const;
|
export const ACCESS_PROVIDER_BYTEPLUS = "byteplus" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_CLOUDFLARE = "cloudflare" as const;
|
export const ACCESS_PROVIDER_CLOUDFLARE = "cloudflare" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_DOGECLOUD = "dogecloud" as const;
|
export const ACCESS_PROVIDER_DOGECLOUD = "dogecloud" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_GODADDY = "godaddy" as const;
|
export const ACCESS_PROVIDER_GODADDY = "godaddy" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_HUAWEICLOUD = "huaweicloud" as const;
|
export const ACCESS_PROVIDER_HUAWEICLOUD = "huaweicloud" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_KUBERNETES = "k8s" as const;
|
export const ACCESS_PROVIDER_KUBERNETES = "k8s" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_LOCAL = "local" as const;
|
export const ACCESS_PROVIDER_LOCAL = "local" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_NAMEDOTCOM = "namedotcom" as const;
|
export const ACCESS_PROVIDER_NAMEDOTCOM = "namedotcom" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_NAMESILO = "namesilo" as const;
|
export const ACCESS_PROVIDER_NAMESILO = "namesilo" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_POWERDNS = "powerdns" as const;
|
export const ACCESS_PROVIDER_POWERDNS = "powerdns" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_QINIU = "qiniu" as const;
|
export const ACCESS_PROVIDER_QINIU = "qiniu" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_SSH = "ssh" as const;
|
export const ACCESS_PROVIDER_SSH = "ssh" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_TENCENTCLOUD = "tencentcloud" as const;
|
export const ACCESS_PROVIDER_TENCENTCLOUD = "tencentcloud" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_VOLCENGINE = "volcengine" as const;
|
export const ACCESS_PROVIDER_VOLCENGINE = "volcengine" as const;
|
||||||
export const ACCESS_PROVIDER_TYPE_WEBHOOK = "webhook" as const;
|
export const ACCESS_PROVIDER_WEBHOOK = "webhook" as const;
|
||||||
export const ACCESS_PROVIDER_TYPES = Object.freeze({
|
export const ACCESS_PROVIDERS = Object.freeze({
|
||||||
ACMEHTTPREQ: ACCESS_PROVIDER_TYPE_ACMEHTTPREQ,
|
ACMEHTTPREQ: ACCESS_PROVIDER_ACMEHTTPREQ,
|
||||||
ALIYUN: ACCESS_PROVIDER_TYPE_ALIYUN,
|
ALIYUN: ACCESS_PROVIDER_ALIYUN,
|
||||||
AWS: ACCESS_PROVIDER_TYPE_AWS,
|
AWS: ACCESS_PROVIDER_AWS,
|
||||||
BAIDUCLOUD: ACCESS_PROVIDER_TYPE_BAIDUCLOUD,
|
BAIDUCLOUD: ACCESS_PROVIDER_BAIDUCLOUD,
|
||||||
BYTEPLUS: ACCESS_PROVIDER_TYPE_BYTEPLUS,
|
BYTEPLUS: ACCESS_PROVIDER_BYTEPLUS,
|
||||||
CLOUDFLARE: ACCESS_PROVIDER_TYPE_CLOUDFLARE,
|
CLOUDFLARE: ACCESS_PROVIDER_CLOUDFLARE,
|
||||||
DOGECLOUD: ACCESS_PROVIDER_TYPE_DOGECLOUD,
|
DOGECLOUD: ACCESS_PROVIDER_DOGECLOUD,
|
||||||
GODADDY: ACCESS_PROVIDER_TYPE_GODADDY,
|
GODADDY: ACCESS_PROVIDER_GODADDY,
|
||||||
HUAWEICLOUD: ACCESS_PROVIDER_TYPE_HUAWEICLOUD,
|
HUAWEICLOUD: ACCESS_PROVIDER_HUAWEICLOUD,
|
||||||
KUBERNETES: ACCESS_PROVIDER_TYPE_KUBERNETES,
|
KUBERNETES: ACCESS_PROVIDER_KUBERNETES,
|
||||||
LOCAL: ACCESS_PROVIDER_TYPE_LOCAL,
|
LOCAL: ACCESS_PROVIDER_LOCAL,
|
||||||
NAMEDOTCOM: ACCESS_PROVIDER_TYPE_NAMEDOTCOM,
|
NAMEDOTCOM: ACCESS_PROVIDER_NAMEDOTCOM,
|
||||||
NAMESILO: ACCESS_PROVIDER_TYPE_NAMESILO,
|
NAMESILO: ACCESS_PROVIDER_NAMESILO,
|
||||||
POWERDNS: ACCESS_PROVIDER_TYPE_POWERDNS,
|
POWERDNS: ACCESS_PROVIDER_POWERDNS,
|
||||||
QINIU: ACCESS_PROVIDER_TYPE_QINIU,
|
QINIU: ACCESS_PROVIDER_QINIU,
|
||||||
SSH: ACCESS_PROVIDER_TYPE_SSH,
|
SSH: ACCESS_PROVIDER_SSH,
|
||||||
TENCENTCLOUD: ACCESS_PROVIDER_TYPE_TENCENTCLOUD,
|
TENCENTCLOUD: ACCESS_PROVIDER_TENCENTCLOUD,
|
||||||
VOLCENGINE: ACCESS_PROVIDER_TYPE_VOLCENGINE,
|
VOLCENGINE: ACCESS_PROVIDER_VOLCENGINE,
|
||||||
WEBHOOK: ACCESS_PROVIDER_TYPE_WEBHOOK,
|
WEBHOOK: ACCESS_PROVIDER_WEBHOOK,
|
||||||
} as const);
|
} as const);
|
||||||
|
|
||||||
export type AccessProviderTypes = (typeof ACCESS_PROVIDER_TYPES)[keyof typeof ACCESS_PROVIDER_TYPES];
|
export type AccessProviderType = (typeof ACCESS_PROVIDERS)[keyof typeof ACCESS_PROVIDERS];
|
||||||
|
|
||||||
export const ACCESS_PROVIDER_USAGE_ALL = "all" as const;
|
export const ACCESS_USAGE_ALL = "all" as const;
|
||||||
export const ACCESS_PROVIDER_USAGE_APPLY = "apply" as const;
|
export const ACCESS_USAGE_APPLY = "apply" as const;
|
||||||
export const ACCESS_PROVIDER_USAGE_DEPLOY = "deploy" as const;
|
export const ACCESS_USAGE_DEPLOY = "deploy" as const;
|
||||||
export const ACCESS_PROVIDER_USAGES = Object.freeze({
|
export const ACCESS_USAGES = Object.freeze({
|
||||||
ALL: ACCESS_PROVIDER_USAGE_ALL,
|
ALL: ACCESS_USAGE_ALL,
|
||||||
APPLY: ACCESS_PROVIDER_USAGE_APPLY,
|
APPLY: ACCESS_USAGE_APPLY,
|
||||||
DEPLOY: ACCESS_PROVIDER_USAGE_DEPLOY,
|
DEPLOY: ACCESS_USAGE_DEPLOY,
|
||||||
} as const);
|
} as const);
|
||||||
|
|
||||||
export type AccessProviderUsages = (typeof ACCESS_PROVIDER_USAGES)[keyof typeof ACCESS_PROVIDER_USAGES];
|
export type AccessUsageType = (typeof ACCESS_USAGES)[keyof typeof ACCESS_USAGES];
|
||||||
|
|
||||||
// #region AccessModel
|
// #region AccessModel
|
||||||
export interface AccessModel extends BaseModel {
|
export interface AccessModel extends BaseModel {
|
||||||
name: string;
|
name: string;
|
||||||
configType: string;
|
configType: string;
|
||||||
usage: AccessProviderUsages;
|
usage: AccessUsageType;
|
||||||
config: /*
|
config: /*
|
||||||
注意:如果追加新的类型,请保持以 ASCII 排序。
|
注意:如果追加新的类型,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new type, please keep ASCII order.
|
NOTICE: If you add new type, please keep ASCII order.
|
||||||
@ -193,7 +193,7 @@ export type AccessProvider = {
|
|||||||
type: string;
|
type: string;
|
||||||
name: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
usage: AccessProviderUsages;
|
usage: AccessUsageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const accessProvidersMap: Map<AccessProvider["type"], AccessProvider> = new Map(
|
export const accessProvidersMap: Map<AccessProvider["type"], AccessProvider> = new Map(
|
||||||
@ -202,25 +202,25 @@ export const accessProvidersMap: Map<AccessProvider["type"], AccessProvider> = n
|
|||||||
NOTICE: The following order determines the order displayed at the frontend.
|
NOTICE: The following order determines the order displayed at the frontend.
|
||||||
*/
|
*/
|
||||||
[
|
[
|
||||||
[ACCESS_PROVIDER_TYPE_LOCAL, "common.provider.local", "/imgs/providers/local.svg", "deploy"],
|
[ACCESS_PROVIDER_LOCAL, "common.provider.local", "/imgs/providers/local.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_SSH, "common.provider.ssh", "/imgs/providers/ssh.svg", "deploy"],
|
[ACCESS_PROVIDER_SSH, "common.provider.ssh", "/imgs/providers/ssh.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_WEBHOOK, "common.provider.webhook", "/imgs/providers/webhook.svg", "deploy"],
|
[ACCESS_PROVIDER_WEBHOOK, "common.provider.webhook", "/imgs/providers/webhook.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_ALIYUN, "common.provider.aliyun", "/imgs/providers/aliyun.svg", "all"],
|
[ACCESS_PROVIDER_ALIYUN, "common.provider.aliyun", "/imgs/providers/aliyun.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_TENCENTCLOUD, "common.provider.tencentcloud", "/imgs/providers/tencentcloud.svg", "all"],
|
[ACCESS_PROVIDER_TENCENTCLOUD, "common.provider.tencentcloud", "/imgs/providers/tencentcloud.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_HUAWEICLOUD, "common.provider.huaweicloud", "/imgs/providers/huaweicloud.svg", "all"],
|
[ACCESS_PROVIDER_HUAWEICLOUD, "common.provider.huaweicloud", "/imgs/providers/huaweicloud.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_BAIDUCLOUD, "common.provider.baiducloud", "/imgs/providers/baiducloud.svg", "all"],
|
[ACCESS_PROVIDER_BAIDUCLOUD, "common.provider.baiducloud", "/imgs/providers/baiducloud.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_QINIU, "common.provider.qiniu", "/imgs/providers/qiniu.svg", "deploy"],
|
[ACCESS_PROVIDER_QINIU, "common.provider.qiniu", "/imgs/providers/qiniu.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_DOGECLOUD, "common.provider.dogecloud", "/imgs/providers/dogecloud.svg", "deploy"],
|
[ACCESS_PROVIDER_DOGECLOUD, "common.provider.dogecloud", "/imgs/providers/dogecloud.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_VOLCENGINE, "common.provider.volcengine", "/imgs/providers/volcengine.svg", "all"],
|
[ACCESS_PROVIDER_VOLCENGINE, "common.provider.volcengine", "/imgs/providers/volcengine.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_BYTEPLUS, "common.provider.byteplus", "/imgs/providers/byteplus.svg", "all"],
|
[ACCESS_PROVIDER_BYTEPLUS, "common.provider.byteplus", "/imgs/providers/byteplus.svg", "all"],
|
||||||
[ACCESS_PROVIDER_TYPE_AWS, "common.provider.aws", "/imgs/providers/aws.svg", "apply"],
|
[ACCESS_PROVIDER_AWS, "common.provider.aws", "/imgs/providers/aws.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_CLOUDFLARE, "common.provider.cloudflare", "/imgs/providers/cloudflare.svg", "apply"],
|
[ACCESS_PROVIDER_CLOUDFLARE, "common.provider.cloudflare", "/imgs/providers/cloudflare.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_NAMEDOTCOM, "common.provider.namedotcom", "/imgs/providers/namedotcom.svg", "apply"],
|
[ACCESS_PROVIDER_NAMEDOTCOM, "common.provider.namedotcom", "/imgs/providers/namedotcom.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_NAMESILO, "common.provider.namesilo", "/imgs/providers/namesilo.svg", "apply"],
|
[ACCESS_PROVIDER_NAMESILO, "common.provider.namesilo", "/imgs/providers/namesilo.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_GODADDY, "common.provider.godaddy", "/imgs/providers/godaddy.svg", "apply"],
|
[ACCESS_PROVIDER_GODADDY, "common.provider.godaddy", "/imgs/providers/godaddy.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_POWERDNS, "common.provider.powerdns", "/imgs/providers/powerdns.svg", "apply"],
|
[ACCESS_PROVIDER_POWERDNS, "common.provider.powerdns", "/imgs/providers/powerdns.svg", "apply"],
|
||||||
[ACCESS_PROVIDER_TYPE_KUBERNETES, "common.provider.kubernetes", "/imgs/providers/kubernetes.svg", "deploy"],
|
[ACCESS_PROVIDER_KUBERNETES, "common.provider.kubernetes", "/imgs/providers/kubernetes.svg", "deploy"],
|
||||||
[ACCESS_PROVIDER_TYPE_ACMEHTTPREQ, "common.provider.acmehttpreq", "/imgs/providers/acmehttpreq.svg", "apply"],
|
[ACCESS_PROVIDER_ACMEHTTPREQ, "common.provider.acmehttpreq", "/imgs/providers/acmehttpreq.svg", "apply"],
|
||||||
].map(([type, name, icon, usage]) => [type, { type, name, icon, usage: usage as AccessProviderUsages }])
|
].map(([type, name, icon, usage]) => [type, { type, name, icon, usage: usage as AccessUsageType }])
|
||||||
);
|
);
|
||||||
// #endregion
|
// #endregion
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import {
|
import {
|
||||||
ACCESS_PROVIDER_TYPE_ALIYUN,
|
ACCESS_PROVIDER_ALIYUN,
|
||||||
ACCESS_PROVIDER_TYPE_BAIDUCLOUD,
|
ACCESS_PROVIDER_BAIDUCLOUD,
|
||||||
ACCESS_PROVIDER_TYPE_BYTEPLUS,
|
ACCESS_PROVIDER_BYTEPLUS,
|
||||||
ACCESS_PROVIDER_TYPE_DOGECLOUD,
|
ACCESS_PROVIDER_DOGECLOUD,
|
||||||
ACCESS_PROVIDER_TYPE_HUAWEICLOUD,
|
ACCESS_PROVIDER_HUAWEICLOUD,
|
||||||
ACCESS_PROVIDER_TYPE_KUBERNETES,
|
ACCESS_PROVIDER_KUBERNETES,
|
||||||
ACCESS_PROVIDER_TYPE_LOCAL,
|
ACCESS_PROVIDER_LOCAL,
|
||||||
ACCESS_PROVIDER_TYPE_QINIU,
|
ACCESS_PROVIDER_QINIU,
|
||||||
ACCESS_PROVIDER_TYPE_SSH,
|
ACCESS_PROVIDER_SSH,
|
||||||
ACCESS_PROVIDER_TYPE_TENCENTCLOUD,
|
ACCESS_PROVIDER_TENCENTCLOUD,
|
||||||
ACCESS_PROVIDER_TYPE_VOLCENGINE,
|
ACCESS_PROVIDER_VOLCENGINE,
|
||||||
ACCESS_PROVIDER_TYPE_WEBHOOK,
|
ACCESS_PROVIDER_WEBHOOK,
|
||||||
} from "./access";
|
} from "./access";
|
||||||
|
|
||||||
export type KVType = {
|
export type KVType = {
|
||||||
@ -34,7 +34,7 @@ export type ApplyConfig = {
|
|||||||
email: string;
|
email: string;
|
||||||
keyAlgorithm?: string;
|
keyAlgorithm?: string;
|
||||||
nameservers?: string;
|
nameservers?: string;
|
||||||
timeout?: number;
|
propagationTimeout?: number;
|
||||||
disableFollowCNAME?: boolean;
|
disableFollowCNAME?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -50,29 +50,29 @@ export const deployTargetList: string[][] = [
|
|||||||
注意:此处的顺序决定显示在前端的顺序。
|
注意:此处的顺序决定显示在前端的顺序。
|
||||||
NOTICE: The following order determines the order displayed at the frontend.
|
NOTICE: The following order determines the order displayed at the frontend.
|
||||||
*/
|
*/
|
||||||
[`${ACCESS_PROVIDER_TYPE_LOCAL}`, "common.provider.local", "/imgs/providers/local.svg"],
|
[`${ACCESS_PROVIDER_LOCAL}`, "common.provider.local", "/imgs/providers/local.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_SSH}`, "common.provider.ssh", "/imgs/providers/ssh.svg"],
|
[`${ACCESS_PROVIDER_SSH}`, "common.provider.ssh", "/imgs/providers/ssh.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_WEBHOOK}`, "common.provider.webhook", "/imgs/providers/webhook.svg"],
|
[`${ACCESS_PROVIDER_WEBHOOK}`, "common.provider.webhook", "/imgs/providers/webhook.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-oss`, "common.provider.aliyun.oss", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-oss`, "common.provider.aliyun.oss", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-cdn`, "common.provider.aliyun.cdn", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-cdn`, "common.provider.aliyun.cdn", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-dcdn`, "common.provider.aliyun.dcdn", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-dcdn`, "common.provider.aliyun.dcdn", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-clb`, "common.provider.aliyun.clb", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-clb`, "common.provider.aliyun.clb", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-alb`, "common.provider.aliyun.alb", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-alb`, "common.provider.aliyun.alb", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_ALIYUN}-nlb`, "common.provider.aliyun.nlb", "/imgs/providers/aliyun.svg"],
|
[`${ACCESS_PROVIDER_ALIYUN}-nlb`, "common.provider.aliyun.nlb", "/imgs/providers/aliyun.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-cdn`, "common.provider.tencentcloud.cdn", "/imgs/providers/tencentcloud.svg"],
|
[`${ACCESS_PROVIDER_TENCENTCLOUD}-cdn`, "common.provider.tencentcloud.cdn", "/imgs/providers/tencentcloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-ecdn`, "common.provider.tencentcloud.ecdn", "/imgs/providers/tencentcloud.svg"],
|
[`${ACCESS_PROVIDER_TENCENTCLOUD}-ecdn`, "common.provider.tencentcloud.ecdn", "/imgs/providers/tencentcloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-clb`, "common.provider.tencentcloud.clb", "/imgs/providers/tencentcloud.svg"],
|
[`${ACCESS_PROVIDER_TENCENTCLOUD}-clb`, "common.provider.tencentcloud.clb", "/imgs/providers/tencentcloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-cos`, "common.provider.tencentcloud.cos", "/imgs/providers/tencentcloud.svg"],
|
[`${ACCESS_PROVIDER_TENCENTCLOUD}-cos`, "common.provider.tencentcloud.cos", "/imgs/providers/tencentcloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_TENCENTCLOUD}-eo`, "common.provider.tencentcloud.eo", "/imgs/providers/tencentcloud.svg"],
|
[`${ACCESS_PROVIDER_TENCENTCLOUD}-eo`, "common.provider.tencentcloud.eo", "/imgs/providers/tencentcloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_HUAWEICLOUD}-cdn`, "common.provider.huaweicloud.cdn", "/imgs/providers/huaweicloud.svg"],
|
[`${ACCESS_PROVIDER_HUAWEICLOUD}-cdn`, "common.provider.huaweicloud.cdn", "/imgs/providers/huaweicloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_HUAWEICLOUD}-elb`, "common.provider.huaweicloud.elb", "/imgs/providers/huaweicloud.svg"],
|
[`${ACCESS_PROVIDER_HUAWEICLOUD}-elb`, "common.provider.huaweicloud.elb", "/imgs/providers/huaweicloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_BAIDUCLOUD}-cdn`, "common.provider.baiducloud.cdn", "/imgs/providers/baiducloud.svg"],
|
[`${ACCESS_PROVIDER_BAIDUCLOUD}-cdn`, "common.provider.baiducloud.cdn", "/imgs/providers/baiducloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_VOLCENGINE}-cdn`, "common.provider.volcengine.cdn", "/imgs/providers/volcengine.svg"],
|
[`${ACCESS_PROVIDER_VOLCENGINE}-cdn`, "common.provider.volcengine.cdn", "/imgs/providers/volcengine.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_VOLCENGINE}-live`, "common.provider.volcengine.live", "/imgs/providers/volcengine.svg"],
|
[`${ACCESS_PROVIDER_VOLCENGINE}-live`, "common.provider.volcengine.live", "/imgs/providers/volcengine.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_QINIU}-cdn`, "common.provider.qiniu.cdn", "/imgs/providers/qiniu.svg"],
|
[`${ACCESS_PROVIDER_QINIU}-cdn`, "common.provider.qiniu.cdn", "/imgs/providers/qiniu.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_DOGECLOUD}-cdn`, "common.provider.dogecloud.cdn", "/imgs/providers/dogecloud.svg"],
|
[`${ACCESS_PROVIDER_DOGECLOUD}-cdn`, "common.provider.dogecloud.cdn", "/imgs/providers/dogecloud.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_BYTEPLUS}-cdn`, "common.provider.byteplus.cdn", "/imgs/providers/byteplus.svg"],
|
[`${ACCESS_PROVIDER_BYTEPLUS}-cdn`, "common.provider.byteplus.cdn", "/imgs/providers/byteplus.svg"],
|
||||||
[`${ACCESS_PROVIDER_TYPE_KUBERNETES}-secret`, "common.provider.kubernetes.secret", "/imgs/providers/kubernetes.svg"],
|
[`${ACCESS_PROVIDER_KUBERNETES}-secret`, "common.provider.kubernetes.secret", "/imgs/providers/kubernetes.svg"],
|
||||||
];
|
];
|
||||||
|
|
||||||
export const deployTargetsMap: Map<DeployTarget["type"], DeployTarget> = new Map(
|
export const deployTargetsMap: Map<DeployTarget["type"], DeployTarget> = new Map(
|
||||||
|
@ -11,13 +11,6 @@
|
|||||||
"common.button.save": "Save",
|
"common.button.save": "Save",
|
||||||
"common.button.submit": "Submit",
|
"common.button.submit": "Submit",
|
||||||
|
|
||||||
"common.text.domain": "Domain",
|
|
||||||
"common.text.domain.empty": "No Domain",
|
|
||||||
"common.text.ip": "IP Address",
|
|
||||||
"common.text.ip.empty": "No IP address",
|
|
||||||
"common.text.dns": "Domain Name Server",
|
|
||||||
"common.text.dns.empty": "No DNS",
|
|
||||||
"common.text.ca": "Certificate Authority",
|
|
||||||
"common.text.copied": "Copied",
|
"common.text.copied": "Copied",
|
||||||
"common.text.nodata": "No data available",
|
"common.text.nodata": "No data available",
|
||||||
"common.text.operation_succeeded": "Operation succeeded",
|
"common.text.operation_succeeded": "Operation succeeded",
|
||||||
@ -30,18 +23,12 @@
|
|||||||
"common.menu.logout": "Logout",
|
"common.menu.logout": "Logout",
|
||||||
"common.menu.document": "Document",
|
"common.menu.document": "Document",
|
||||||
|
|
||||||
"common.pagination.next": "Next",
|
|
||||||
"common.pagination.prev": "Previous",
|
|
||||||
"common.pagination.more": "More pages",
|
|
||||||
|
|
||||||
"common.theme.light": "Light",
|
"common.theme.light": "Light",
|
||||||
"common.theme.dark": "Dark",
|
"common.theme.dark": "Dark",
|
||||||
"common.theme.system": "System",
|
"common.theme.system": "System",
|
||||||
|
|
||||||
"common.errmsg.string_max": "Please enter no more than {{max}} characters",
|
"common.errmsg.string_max": "Please enter no more than {{max}} characters",
|
||||||
"common.errmsg.email_empty": "Please enter email",
|
|
||||||
"common.errmsg.email_invalid": "Please enter a valid email address",
|
"common.errmsg.email_invalid": "Please enter a valid email address",
|
||||||
"common.errmsg.email_duplicate": "Email already exists",
|
|
||||||
"common.errmsg.domain_invalid": "Please enter domain",
|
"common.errmsg.domain_invalid": "Please enter domain",
|
||||||
"common.errmsg.host_invalid": "Please enter a valid domain name or IP",
|
"common.errmsg.host_invalid": "Please enter a valid domain name or IP",
|
||||||
"common.errmsg.port_invalid": "Please enter a valid port",
|
"common.errmsg.port_invalid": "Please enter a valid port",
|
||||||
|
@ -11,13 +11,6 @@
|
|||||||
"common.button.save": "保存",
|
"common.button.save": "保存",
|
||||||
"common.button.submit": "提交",
|
"common.button.submit": "提交",
|
||||||
|
|
||||||
"common.text.domain": "域名",
|
|
||||||
"common.text.domain.empty": "无域名",
|
|
||||||
"common.text.ip": "IP 地址",
|
|
||||||
"common.text.ip.empty": "无 IP 地址",
|
|
||||||
"common.text.dns": "DNS(域名服务器)",
|
|
||||||
"common.text.dns.empty": "无 DNS 地址",
|
|
||||||
"common.text.ca": "CA(证书颁发机构)",
|
|
||||||
"common.text.copied": "已复制",
|
"common.text.copied": "已复制",
|
||||||
"common.text.nodata": "暂无数据",
|
"common.text.nodata": "暂无数据",
|
||||||
"common.text.operation_succeeded": "操作成功",
|
"common.text.operation_succeeded": "操作成功",
|
||||||
@ -30,18 +23,12 @@
|
|||||||
"common.menu.logout": "退出登录",
|
"common.menu.logout": "退出登录",
|
||||||
"common.menu.document": "文档",
|
"common.menu.document": "文档",
|
||||||
|
|
||||||
"common.pagination.next": "下一页",
|
|
||||||
"common.pagination.prev": "上一页",
|
|
||||||
"common.pagination.more": "更多",
|
|
||||||
|
|
||||||
"common.theme.light": "浅色",
|
"common.theme.light": "浅色",
|
||||||
"common.theme.dark": "暗黑",
|
"common.theme.dark": "暗黑",
|
||||||
"common.theme.system": "跟随系统",
|
"common.theme.system": "跟随系统",
|
||||||
|
|
||||||
"common.errmsg.string_max": "请输入不超过 {{max}} 个字符",
|
"common.errmsg.string_max": "请输入不超过 {{max}} 个字符",
|
||||||
"common.errmsg.email_empty": "请输入邮箱",
|
|
||||||
"common.errmsg.email_invalid": "请输入正确的邮箱",
|
"common.errmsg.email_invalid": "请输入正确的邮箱",
|
||||||
"common.errmsg.email_duplicate": "邮箱已存在",
|
|
||||||
"common.errmsg.domain_invalid": "请输入正确的域名",
|
"common.errmsg.domain_invalid": "请输入正确的域名",
|
||||||
"common.errmsg.host_invalid": "请输入正确的域名或 IP 地址",
|
"common.errmsg.host_invalid": "请输入正确的域名或 IP 地址",
|
||||||
"common.errmsg.port_invalid": "请输入正确的端口号",
|
"common.errmsg.port_invalid": "请输入正确的端口号",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user