refactor: rename ResourceType to DeployTarget

This commit is contained in:
Fu Diwei
2026-05-20 11:45:37 +08:00
committed by RHQYZ
parent dd5d09978b
commit f0b1e45669
178 changed files with 1266 additions and 1116 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ func init() {
ApiKey: credentials.ApiKey,
AllowInsecureConnections: credentials.AllowInsecureConnections,
NodeName: xmaps.GetString(options.ProviderExtendedConfig, "nodeName"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
WebsiteMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "websiteMatchPattern"),
WebsiteId: xmaps.GetInt64(options.ProviderExtendedConfig, "websiteId"),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
+1 -1
View File
@@ -21,7 +21,7 @@ func init() {
AccessKeySecret: credentials.AccessKeySecret,
ResourceGroupId: credentials.ResourceGroupId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
+1 -1
View File
@@ -21,7 +21,7 @@ func init() {
AccessKeySecret: credentials.AccessKeySecret,
ResourceGroupId: credentials.ResourceGroupId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerPort: xmaps.GetOrDefaultInt32(options.ProviderExtendedConfig, "listenerPort", 443),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeySecret: credentials.AccessKeySecret,
ResourceGroupId: credentials.ResourceGroupId,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
AcceleratorId: xmaps.GetString(options.ProviderExtendedConfig, "acceleratorId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
+1 -1
View File
@@ -21,7 +21,7 @@ func init() {
AccessKeySecret: credentials.AccessKeySecret,
ResourceGroupId: credentials.ResourceGroupId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
ServerUrl: credentials.ServerUrl,
ApiKey: credentials.ApiKey,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerPort: xmaps.GetInt32(options.ProviderExtendedConfig, "listenerPort"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerPort: xmaps.GetInt32(options.ProviderExtendedConfig, "listenerPort"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
@@ -18,7 +18,7 @@ func init() {
provider, err := baishancdn.NewDeployer(&baishancdn.DeployerConfig{
ApiToken: credentials.ApiToken,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
DomainMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "domainMatchPattern"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
+1 -1
View File
@@ -21,7 +21,7 @@ func init() {
ApiKey: credentials.ApiKey,
ApiSecret: credentials.ApiSecret,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
SiteId: xmaps.GetString(options.ProviderExtendedConfig, "siteId"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
+1 -1
View File
@@ -21,7 +21,7 @@ func init() {
Username: credentials.Username,
ApiToken: credentials.ApiToken,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
})
return provider, err
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
RegionId: xmaps.GetString(options.ProviderExtendedConfig, "regionId"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
+1 -1
View File
@@ -22,7 +22,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKey: credentials.AccessKey,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
+1 -1
View File
@@ -22,7 +22,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKey: credentials.AccessKey,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
@@ -21,7 +21,7 @@ func init() {
SecretAccessKey: credentials.SecretAccessKey,
EnterpriseProjectId: credentials.EnterpriseProjectId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
@@ -21,7 +21,7 @@ func init() {
SecretAccessKey: credentials.SecretAccessKey,
EnterpriseProjectId: credentials.EnterpriseProjectId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
@@ -21,7 +21,7 @@ func init() {
SecretAccessKey: credentials.SecretAccessKey,
EnterpriseProjectId: credentials.EnterpriseProjectId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
})
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeySecret: credentials.AccessKeySecret,
RegionId: xmaps.GetString(options.ProviderExtendedConfig, "regionId"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
ServerUrl: credentials.ServerUrl,
ApiToken: credentials.ApiToken,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
Workspace: xmaps.GetString(options.ProviderExtendedConfig, "workspace"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
+1 -1
View File
@@ -19,7 +19,7 @@ func init() {
provider, err := ksyuncdn.NewDeployer(&ksyuncdn.DeployerConfig{
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
DomainMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "domainMatchPattern"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
+1 -1
View File
@@ -19,7 +19,7 @@ func init() {
provider, err := ksyunslb.NewDeployer(&ksyunslb.DeployerConfig{
AccessKeyId: credentials.AccessKeyId,
SecretAccessKey: credentials.SecretAccessKey,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
+1 -1
View File
@@ -23,7 +23,7 @@ func init() {
Username: credentials.Username,
Password: credentials.Password,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
ClientId: xmaps.GetInt64(options.ProviderExtendedConfig, "clientId"),
})
+1 -1
View File
@@ -18,7 +18,7 @@ func init() {
provider, err := netlify.NewDeployer(&netlify.DeployerConfig{
ApiToken: credentials.ApiToken,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
SiteId: xmaps.GetString(options.ProviderExtendedConfig, "siteId"),
})
return provider, err
@@ -23,7 +23,7 @@ func init() {
Password: credentials.Password,
ApiToken: credentials.ApiToken,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
HostType: xmaps.GetString(options.ProviderExtendedConfig, "hostType"),
HostMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "hostMatchPattern"),
HostId: xmaps.GetInt64(options.ProviderExtendedConfig, "hostId"),
+1 -1
View File
@@ -24,7 +24,7 @@ func init() {
AccessTokenId: credentials.AccessTokenId,
AccessToken: credentials.AccessToken,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
SiteNames: lo.Filter(strings.Split(xmaps.GetString(options.ProviderExtendedConfig, "siteNames"), ";"), func(s string, _ int) bool { return s != "" }),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
})
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
ServerUrl: credentials.ServerUrl,
ApiToken: credentials.ApiToken,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
ServerUrl: credentials.ServerUrl,
ApiKey: credentials.ApiKey,
AllowInsecureConnections: credentials.AllowInsecureConnections,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
return provider, err
@@ -21,7 +21,7 @@ func init() {
SecretKey: credentials.SecretKey,
Endpoint: xmaps.GetString(options.ProviderExtendedConfig, "endpoint"),
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
@@ -20,7 +20,7 @@ func init() {
SecretId: credentials.SecretId,
SecretKey: credentials.SecretKey,
Endpoint: xmaps.GetString(options.ProviderExtendedConfig, "endpoint"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
ProxyId: xmaps.GetString(options.ProviderExtendedConfig, "proxyId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
@@ -21,7 +21,7 @@ func init() {
PublicKey: credentials.PublicKey,
ProjectId: credentials.ProjectId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
@@ -21,7 +21,7 @@ func init() {
PublicKey: credentials.PublicKey,
ProjectId: credentials.ProjectId,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
VServerId: xmaps.GetString(options.ProviderExtendedConfig, "vserverId"),
})
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeySecret: credentials.SecretAccessKey,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeySecret: credentials.SecretAccessKey,
Region: xmaps.GetString(options.ProviderExtendedConfig, "region"),
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
LoadbalancerId: xmaps.GetString(options.ProviderExtendedConfig, "loadbalancerId"),
ListenerId: xmaps.GetString(options.ProviderExtendedConfig, "listenerId"),
})
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeyPassword: credentials.AccessKeyPassword,
ResourceGroupId: credentials.ResourceGroupId,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
DomainMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "domainMatchPattern"),
Domain: xmaps.GetString(options.ProviderExtendedConfig, "domain"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
@@ -20,7 +20,7 @@ func init() {
AccessKeyId: credentials.AccessKeyId,
AccessKeyPassword: credentials.AccessKeyPassword,
ResourceGroupId: credentials.ResourceGroupId,
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
DeployTarget: xmaps.GetString(options.ProviderExtendedConfig, "deployTarget"),
AcceleratorId: xmaps.GetString(options.ProviderExtendedConfig, "acceleratorId"),
CertificateId: xmaps.GetString(options.ProviderExtendedConfig, "certificateId"),
})
+155
View File
@@ -0,0 +1,155 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
snaps "github.com/certimate-go/certimate/migrations/snaps/v0.4"
)
func init() {
m.Register(func(app core.App) error {
tracer := NewTracer("v0.4.23")
tracer.Printf("go ...")
// adapt to new workflow data structure
{
walker := &snaps.WorkflowGraphWalker{}
walker.Define(func(node *snaps.WorkflowNode) (_changed bool, _err error) {
_changed = false
_err = nil
if node.Type != "bizDeploy" {
return
}
nodeCfg := node.Data.Config
switch nodeCfg["provider"] {
case
"1panel",
"aliyun-alb",
"aliyun-clb",
"aliyun-ga",
"aliyun-nlb",
"apisix",
"baiducloud-appblb",
"baiducloud-blb",
"baishan-cdn",
"cdnfly",
"cpanel",
"ctcccloud-elb",
"flexcdn",
"goedge",
"huaweicloud-apig",
"huaweicloud-elb",
"huaweicloud-waf",
"jdcloud-alb",
"kong",
"ksyun-cdn",
"ksyun-slb",
"lecdn",
"netlify",
"nginxproxymanager",
"ratpanel",
"safeline",
"samwaf",
"tencentcloud-clb",
"tencentcloud-gaap",
"ucloud-uclb",
"volcengine-alb",
"volcengine-clb",
"zenlayer-cdn",
"zenlayer-ga":
{
if providerCfg, ok := nodeCfg["providerConfig"].(map[string]any); ok {
providerCfg["deployTarget"] = providerCfg["resourceType"]
delete(providerCfg, "resourceType")
nodeCfg["providerConfig"] = providerCfg
_changed = true
return
}
}
}
return
})
// update collection `workflow`
// - migrate field `graphDraft` / `graphContent`
{
collection, err := app.FindCollectionByNameOrId("tovyif5ax6j62ur")
if err != nil {
return err
}
records, err := app.FindAllRecords(collection)
if err != nil {
return err
}
for _, record := range records {
changed := false
if ret, err := walker.Migrate(record, "graphDraft"); err != nil {
return err
} else {
changed = changed || ret
}
if ret, err := walker.Migrate(record, "graphContent"); err != nil {
return err
} else {
changed = changed || ret
}
if changed {
if err := app.Save(record); err != nil {
return err
}
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
}
}
}
// update collection `workflow_run`
// - migrate field `graph`
{
collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz")
if err != nil {
return err
}
records, err := app.FindAllRecords(collection)
if err != nil {
return err
}
for _, record := range records {
changed := false
if ret, err := walker.Migrate(record, "graph"); err != nil {
return err
} else {
changed = changed || ret
}
if changed {
if err := app.Save(record); err != nil {
return err
}
tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name)
}
}
}
}
tracer.Printf("done")
return nil
}, func(app core.App) error {
return nil
})
}
+9 -9
View File
@@ -31,16 +31,16 @@ type DeployerConfig struct {
// 子节点名称。
// 选填。
NodeName string `json:"nodeName,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 域名匹配模式。
// 零值时默认值 [WEBSITE_MATCH_PATTERN_SPECIFIED]。
WebsiteMatchPattern string `json:"websiteMatchPattern,omitempty"`
// 网站 ID。
// 部署资源类型为 [RESOURCE_TYPE_WEBSITE]、且匹配模式非 [WEBSITE_MATCH_PATTERN_CERTSAN] 时必填。
// 部署目标为 [DEPLOY_TARGET_WEBSITE]、且匹配模式非 [WEBSITE_MATCH_PATTERN_CERTSAN] 时必填。
WebsiteId int64 `json:"websiteId,omitempty"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId int64 `json:"certificateId,omitempty"`
}
@@ -93,20 +93,20 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_WEBSITE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_WEBSITE:
if err := d.deployToWebsite(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_CERTIFICATE:
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -49,7 +49,7 @@ func TestProvider(t *testing.T) {
ApiVersion: fApiVersion,
ApiKey: fApiKey,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_WEBSITE,
DeployTarget: impl.DEPLOY_TARGET_WEBSITE,
WebsiteMatchPattern: impl.WEBSITE_MATCH_PATTERN_SPECIFIED,
WebsiteId: fWebsiteId,
})
@@ -67,7 +67,7 @@ func TestProvider(t *testing.T) {
ApiVersion: fApiVersion,
ApiKey: fApiKey,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
+4 -4
View File
@@ -1,10 +1,10 @@
package onepanel
const (
// 资源类型:替换指定网站的证书。
RESOURCE_TYPE_WEBSITE = "website"
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定网站的证书。
DEPLOY_TARGET_WEBSITE = "website"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
const (
@@ -32,16 +32,16 @@ type DeployerConfig struct {
ResourceGroupId string `json:"resourceGroupId,omitempty"`
// 阿里云地域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
// SNI 域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -114,20 +114,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["CertIdentifier"].(string), certX509.DNSNames); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string), certX509.DNSNames); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -51,7 +51,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
Domain: fDomain,
})
@@ -68,7 +68,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
Domain: fDomain,
})
@@ -1,8 +1,8 @@
package aliyunalb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -25,16 +25,16 @@ type DeployerConfig struct {
ResourceGroupId string `json:"resourceGroupId,omitempty"`
// 阿里云地域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听端口。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerPort int32 `json:"listenerPort,omitempty"`
// SNI 域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -94,20 +94,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.CertId); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.CertId); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -51,7 +51,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
Domain: fDomain,
})
@@ -68,7 +68,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
LoadbalancerId: fLoadbalancerId,
ListenerPort: int32(fListenerPort),
Domain: fDomain,
@@ -1,8 +1,8 @@
package aliyunclb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -25,15 +25,15 @@ type DeployerConfig struct {
AccessKeySecret string `json:"accessKeySecret"`
// 阿里云资源组 ID。
ResourceGroupId string `json:"resourceGroupId,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 全球加速实例 ID。
AcceleratorId string `json:"acceleratorId"`
// 全球加速监听 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
// SNI 域名(不支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_ACCELERATOR]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_ACCELERATOR]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -93,20 +93,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_ACCELERATOR:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_ACCELERATOR:
if err := d.deployToAccelerator(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -47,7 +47,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
ResourceType: impl.RESOURCE_TYPE_ACCELERATOR,
DeployTarget: impl.DEPLOY_TARGET_ACCELERATOR,
AcceleratorId: fAcceleratorId,
Domain: fDomain,
})
@@ -63,7 +63,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
Domain: fDomain,
})
@@ -1,8 +1,8 @@
package aliyunga
const (
// 资源类型:部署到指定全球加速器。
RESOURCE_TYPE_ACCELERATOR = "accelerator"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定全球加速器。
DEPLOY_TARGET_ACCELERATOR = "accelerator"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -27,13 +27,13 @@ type DeployerConfig struct {
ResourceGroupId string `json:"resourceGroupId,omitempty"`
// 阿里云地域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
}
@@ -95,20 +95,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.ExtendedData["CertIdentifier"].(string)); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -48,7 +48,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
})
if err != nil {
@@ -64,7 +64,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
})
if err != nil {
@@ -1,8 +1,8 @@
package aliyunnlb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
+7 -7
View File
@@ -20,10 +20,10 @@ type DeployerConfig struct {
ApiKey string `json:"apiKey"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -61,15 +61,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -38,12 +38,11 @@ func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Deploy", func(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
ServerUrl: fServerUrl,
ApiKey: fApiKey,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
+2 -2
View File
@@ -1,6 +1,6 @@
package apisix
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
@@ -24,16 +24,16 @@ type DeployerConfig struct {
SecretAccessKey string `json:"secretAccessKey"`
// 百度智能云区域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听端口。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerPort int32 `json:"listenerPort,omitempty"`
// SNI 域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -89,20 +89,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.CertId); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.CertId); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -47,7 +47,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
Region: fRegion,
LoadbalancerId: fLoadbalancerId,
Domain: fDomain,
@@ -1,8 +1,8 @@
package baiducloudappblb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -24,16 +24,16 @@ type DeployerConfig struct {
SecretAccessKey string `json:"secretAccessKey"`
// 百度智能云区域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听端口。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerPort int32 `json:"listenerPort,omitempty"`
// SNI 域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -89,20 +89,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.CertId); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.CertId); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -47,7 +47,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
Region: fRegion,
LoadbalancerId: fLoadbalancerId,
Domain: fDomain,
@@ -1,8 +1,8 @@
package baiducloudblb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -17,15 +17,15 @@ import (
type DeployerConfig struct {
// 白山云 API Token。
ApiToken string `json:"apiToken"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 域名匹配模式。暂时只支持精确匹配。
// 零值时默认值 [DOMAIN_MATCH_PATTERN_EXACT]。
DomainMatchPattern string `json:"domainMatchPattern,omitempty"`
// 加速域名(支持泛域名)。
Domain string `json:"domain"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -72,20 +72,20 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_DOMAIN:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_DOMAIN:
if err := d.deployToDomain(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_CERTIFICATE:
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -1,10 +1,10 @@
package baishancdn
const (
// 资源类型:替换指定域名的证书。
RESOURCE_TYPE_DOMAIN = "domain"
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定域名的证书。
DEPLOY_TARGET_DOMAIN = "domain"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
const (
+9 -9
View File
@@ -23,13 +23,13 @@ type DeployerConfig struct {
ApiSecret string `json:"apiSecret"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 网站 ID。
// 部署资源类型为 [RESOURCE_TYPE_WEBSITE] 时必填。
// 部署目标为 [DEPLOY_TARGET_WEBSITE] 时必填。
SiteId string `json:"siteId,omitempty"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -67,20 +67,20 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_WEBSITE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_WEBSITE:
if err := d.deployToSite(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_CERTIFICATE:
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -46,7 +46,7 @@ func TestProvider(t *testing.T) {
ApiKey: fApiKey,
ApiSecret: fApiSecret,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
+4 -4
View File
@@ -1,8 +1,8 @@
package cdnfly
const (
// 资源类型:替换指定网站的证书。
RESOURCE_TYPE_WEBSITE = "website"
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定网站的证书。
DEPLOY_TARGET_WEBSITE = "website"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
+2 -2
View File
@@ -1,6 +1,6 @@
package cpanel
const (
// 资源类型:替换指定网站的证书。
RESOURCE_TYPE_WEBSITE = "website"
// 部署目标:替换指定网站的证书。
DEPLOY_TARGET_WEBSITE = "website"
)
+7 -7
View File
@@ -22,10 +22,10 @@ type DeployerConfig struct {
ApiToken string `json:"apiToken"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 网站域名(不支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_WEBSITE] 时必填。
// 部署目标为 [DEPLOY_TARGET_WEBSITE] 时必填。
Domain string `json:"domain,omitempty"`
}
@@ -63,15 +63,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_WEBSITE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_WEBSITE:
if err := d.deployToWebsite(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -46,7 +46,7 @@ func TestProvider(t *testing.T) {
Username: fUsername,
ApiToken: fApiToken,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_WEBSITE,
DeployTarget: impl.DEPLOY_TARGET_WEBSITE,
Domain: fDomain,
})
if err != nil {
@@ -1,8 +1,8 @@
package ctcccloudelb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -22,13 +22,13 @@ type DeployerConfig struct {
SecretAccessKey string `json:"secretAccessKey"`
// 天翼云资源池 ID。
RegionId string `json:"regionId"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡实例 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听器 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
}
@@ -85,20 +85,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.CertId); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.CertId); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -48,7 +48,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
RegionId: fRegionId,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
})
if err != nil {
@@ -64,7 +64,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
RegionId: fRegionId,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
})
if err != nil {
@@ -1,6 +1,6 @@
package flexcdn
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
@@ -25,10 +25,10 @@ type DeployerConfig struct {
AccessKey string `json:"accessKey"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId int64 `json:"certificateId,omitempty"`
}
@@ -66,15 +66,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -47,7 +47,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKey: fAccessKey,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
+2 -2
View File
@@ -1,6 +1,6 @@
package goedge
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
+7 -7
View File
@@ -25,10 +25,10 @@ type DeployerConfig struct {
AccessKey string `json:"accessKey"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId int64 `json:"certificateId,omitempty"`
}
@@ -66,15 +66,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -47,7 +47,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKey: fAccessKey,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
@@ -1,6 +1,6 @@
package huaweicloudapig
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
@@ -28,10 +28,10 @@ type DeployerConfig struct {
EnterpriseProjectId string `json:"enterpriseProjectId,omitempty"`
// 华为云区域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -73,15 +73,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -45,7 +45,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
@@ -1,10 +1,10 @@
package huaweicloudelb
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -31,16 +31,16 @@ type DeployerConfig struct {
EnterpriseProjectId string `json:"enterpriseProjectId,omitempty"`
// 华为云区域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
// 负载均衡器 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 负载均衡监听 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
}
@@ -92,25 +92,25 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_LOADBALANCER:
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -51,7 +51,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
})
if err != nil {
@@ -67,7 +67,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
})
if err != nil {
@@ -83,7 +83,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
Region: fRegion,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
@@ -1,10 +1,10 @@
package huaweicloudwaf
const (
// 资源类型:部署到云模式防护网站。
RESOURCE_TYPE_CLOUDSERVER = "cloudserver"
// 资源类型:部署到独享模式防护网站。
RESOURCE_TYPE_PREMIUMHOST = "premiumhost"
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:部署到云模式防护网站。
DEPLOY_TARGET_CLOUDSERVER = "cloudserver"
// 部署目标:部署到独享模式防护网站。
DEPLOY_TARGET_PREMIUMHOST = "premiumhost"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
@@ -30,14 +30,14 @@ type DeployerConfig struct {
EnterpriseProjectId string `json:"enterpriseProjectId,omitempty"`
// 华为云区域。
Region string `json:"region"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 防护域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_CLOUDSERVER]、[RESOURCE_TYPE_PREMIUMHOST] 时必填。
// 部署目标为 [DEPLOY_TARGET_CLOUDSERVER]、[DEPLOY_TARGET_PREMIUMHOST] 时必填。
Domain string `json:"domain,omitempty"`
// 证书 ID。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
type Deployer struct {
@@ -96,25 +96,25 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CLOUDSERVER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CLOUDSERVER:
if err := d.deployToCloudServer(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_PREMIUMHOST:
case DEPLOY_TARGET_PREMIUMHOST:
if err := d.deployToPremiumHost(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_CERTIFICATE:
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -14,7 +14,6 @@ var (
fAccessKeyId string
fSecretAccessKey string
fRegion string
fResourceType string
fDomain string
)
@@ -24,7 +23,6 @@ func init() {
fp.DefineString(&fAccessKeyId, "ACCESSKEYID")
fp.DefineString(&fSecretAccessKey, "SECRETACCESSKEY")
fp.DefineString(&fRegion, "REGION")
fp.DefineString(&fResourceType, "RESOURCETYPE")
fp.DefineString(&fDomain, "DOMAIN")
}
@@ -37,18 +35,17 @@ Shell command to run this test:
--HUAWEICLOUDWAF_ACCESSKEYID="your-access-key-id" \
--HUAWEICLOUDWAF_SECRETACCESSKEY="your-secret-access-key" \
--HUAWEICLOUDWAF_REGION="cn-north-1" \
--HUAWEICLOUDWAF_RESOURCETYPE="premium" \
--HUAWEICLOUDWAF_DOMAIN="example.com"
*/
func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Deploy", func(t *testing.T) {
t.Run("Deploy_ToPremium", func(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
Region: fRegion,
ResourceType: fResourceType,
DeployTarget: impl.DEPLOY_TARGET_PREMIUMHOST,
Domain: fDomain,
})
if err != nil {
@@ -1,8 +1,8 @@
package jdcloudalb
const (
// 资源类型:部署到指定负载均衡器。
RESOURCE_TYPE_LOADBALANCER = "loadbalancer"
// 资源类型:部署到指定监听器。
RESOURCE_TYPE_LISTENER = "listener"
// 部署目标:部署到指定负载均衡器。
DEPLOY_TARGET_LOADBALANCER = "loadbalancer"
// 部署目标:部署到指定监听器。
DEPLOY_TARGET_LISTENER = "listener"
)
@@ -26,16 +26,16 @@ type DeployerConfig struct {
AccessKeySecret string `json:"accessKeySecret"`
// 京东云地域 ID。
RegionId string `json:"regionId"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 负载均衡器 ID。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER] 时必填。
LoadbalancerId string `json:"loadbalancerId,omitempty"`
// 监听器 ID。
// 部署资源类型为 [RESOURCE_TYPE_LISTENER] 时必填。
// 部署目标为 [DEPLOY_TARGET_LISTENER] 时必填。
ListenerId string `json:"listenerId,omitempty"`
// SNI 域名(支持泛域名)。
// 部署资源类型为 [RESOURCE_TYPE_LOADBALANCER]、[RESOURCE_TYPE_LISTENER] 时选填。
// 部署目标为 [DEPLOY_TARGET_LOADBALANCER]、[DEPLOY_TARGET_LISTENER] 时选填。
Domain string `json:"domain,omitempty"`
}
@@ -93,20 +93,20 @@ func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*dep
d.logger.Info("ssl certificate uploaded", slog.Any("result", upres))
}
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_LOADBALANCER:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_LOADBALANCER:
if err := d.deployToLoadbalancer(ctx, upres.CertId); err != nil {
return nil, err
}
case RESOURCE_TYPE_LISTENER:
case DEPLOY_TARGET_LISTENER:
if err := d.deployToListener(ctx, upres.CertId); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -48,7 +48,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
RegionId: fRegionId,
ResourceType: impl.RESOURCE_TYPE_LOADBALANCER,
DeployTarget: impl.DEPLOY_TARGET_LOADBALANCER,
LoadbalancerId: fLoadbalancerId,
})
if err != nil {
@@ -64,7 +64,7 @@ func TestProvider(t *testing.T) {
AccessKeyId: fAccessKeyId,
AccessKeySecret: fAccessKeySecret,
RegionId: fRegionId,
ResourceType: impl.RESOURCE_TYPE_LISTENER,
DeployTarget: impl.DEPLOY_TARGET_LISTENER,
ListenerId: fListenerId,
})
if err != nil {
+2 -2
View File
@@ -1,6 +1,6 @@
package kong
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
+7 -7
View File
@@ -21,13 +21,13 @@ type DeployerConfig struct {
ApiToken string `json:"apiToken,omitempty"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 工作空间。
// 选填。
Workspace string `json:"workspace,omitempty"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -65,15 +65,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -42,7 +42,7 @@ func TestProvider(t *testing.T) {
ServerUrl: fServerUrl,
ApiToken: fApiToken,
AllowInsecureConnections: true,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
@@ -1,10 +1,10 @@
package ksyuncdn
const (
// 资源类型:替换指定域名的证书。
RESOURCE_TYPE_DOMAIN = "domain"
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定域名的证书。
DEPLOY_TARGET_DOMAIN = "domain"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
const (
@@ -22,15 +22,15 @@ type DeployerConfig struct {
AccessKeyId string `json:"accessKeyId"`
// 金山云 SecretAccessKey。
SecretAccessKey string `json:"secretAccessKey"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 域名匹配模式。
// 零值时默认值 [DOMAIN_MATCH_PATTERN_EXACT]。
DomainMatchPattern string `json:"domainMatchPattern,omitempty"`
// 加速域名(支持泛域名)。
Domain string `json:"domain"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -68,20 +68,20 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_DOMAIN:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_DOMAIN:
if err := d.deployToDomain(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
case RESOURCE_TYPE_CERTIFICATE:
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -44,7 +44,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
ResourceType: impl.RESOURCE_TYPE_DOMAIN,
DeployTarget: impl.DEPLOY_TARGET_DOMAIN,
DomainMatchPattern: impl.DOMAIN_MATCH_PATTERN_EXACT,
Domain: fDomain,
})
@@ -60,7 +60,7 @@ func TestProvider(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
@@ -1,6 +1,6 @@
package ksyunslb
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
@@ -17,10 +17,10 @@ type DeployerConfig struct {
AccessKeyId string `json:"accessKeyId"`
// 金山云 SecretAccessKey。
SecretAccessKey string `json:"secretAccessKey"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId string `json:"certificateId,omitempty"`
}
@@ -58,15 +58,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil
@@ -38,11 +38,10 @@ func TestProvider(t *testing.T) {
fp.Parse()
t.Run("Deploy_ToCertificate", func(t *testing.T) {
provider, err := impl.NewDeployer(&impl.DeployerConfig{
AccessKeyId: fAccessKeyId,
SecretAccessKey: fSecretAccessKey,
ResourceType: impl.RESOURCE_TYPE_CERTIFICATE,
DeployTarget: impl.DEPLOY_TARGET_CERTIFICATE,
CertificateId: fCertificateId,
})
if err != nil {
+2 -2
View File
@@ -1,6 +1,6 @@
package lecdn
const (
// 资源类型:替换指定证书。
RESOURCE_TYPE_CERTIFICATE = "certificate"
// 部署目标:替换指定证书。
DEPLOY_TARGET_CERTIFICATE = "certificate"
)
+8 -8
View File
@@ -27,13 +27,13 @@ type DeployerConfig struct {
Password string `json:"password"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
// 部署资源类型。
ResourceType string `json:"resourceType"`
// 部署目标。
DeployTarget string `json:"deployTarget"`
// 证书 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时必填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时必填。
CertificateId int64 `json:"certificateId,omitempty"`
// 客户 ID。
// 部署资源类型为 [RESOURCE_TYPE_CERTIFICATE] 时选填。
// 部署目标为 [DEPLOY_TARGET_CERTIFICATE] 时选填。
ClientId int64 `json:"clientId,omitempty"`
}
@@ -71,15 +71,15 @@ func (d *Deployer) SetLogger(logger *slog.Logger) {
}
func (d *Deployer) Deploy(ctx context.Context, certPEM, privkeyPEM string) (*deployer.DeployResult, error) {
// 根据部署资源类型决定部署方式
switch d.config.ResourceType {
case RESOURCE_TYPE_CERTIFICATE:
// 根据部署目标决定业务流程
switch d.config.DeployTarget {
case DEPLOY_TARGET_CERTIFICATE:
if err := d.deployToCertificate(ctx, certPEM, privkeyPEM); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported resource type '%s'", d.config.ResourceType)
return nil, fmt.Errorf("unsupported deploy target '%s'", d.config.DeployTarget)
}
return &deployer.DeployResult{}, nil

Some files were not shown because too many files have changed in this diff Show More