refactor: clean code

This commit is contained in:
Fu Diwei
2024-12-27 19:35:50 +08:00
parent 047479426a
commit 86133ba52b
41 changed files with 396 additions and 544 deletions

View File

@@ -4,109 +4,118 @@ import "time"
type Access struct {
Meta
Name string `json:"name"`
Config string `json:"config"`
ConfigType string `json:"configType"`
Deleted time.Time `json:"deleted"`
Usage string `json:"usage"`
Name string `json:"name" db:"name"`
ConfigType string `json:"configType" db:"configType"`
Config string `json:"config" db:"config"`
Usage string `json:"usage" db:"usage"`
DeletedAt time.Time `json:"deleted" db:"deleted"`
}
// 兼容一下原 pocketbase 的 record
func (a *Access) GetString(key string) string {
switch key {
case "name":
return a.Name
default:
return ""
}
}
type AccessProviderType string
type AliyunAccess struct {
AccessKeyId string `json:"accessKeyId"`
AccessKeySecret string `json:"accessKeySecret"`
}
/*
提供商类型常量值。
type ByteplusAccess struct {
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
}
注意:如果追加新的常量值,请保持以 ASCII 排序。
NOTICE: If you add new constant, please keep ASCII order.
*/
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 {
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 {
type ACMEHttpReqAccessConfig struct {
Endpoint string `json:"endpoint"`
Mode string `json:"mode"`
Username string `json:"username"`
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"`
Port string `json:"port"`
Username string `json:"username"`
@@ -115,10 +124,16 @@ type SSHAccess struct {
KeyPassphrase string `json:"keyPassphrase"`
}
type WebhookAccess struct {
Url string `json:"url"`
type TencentCloudAccessConfig struct {
SecretId string `json:"secretId"`
SecretKey string `json:"secretKey"`
}
type KubernetesAccess struct {
KubeConfig string `json:"kubeConfig"`
type VolcEngineAccessConfig struct {
AccessKeyId string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
}
type WebhookAccessConfig struct {
Url string `json:"url"`
}