qiniu cdn supports wildcard domain deployment

This commit is contained in:
yoan
2024-10-22 15:41:44 +08:00
parent 4e86c1eb45
commit dbfb84ec6d
2 changed files with 32 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
package domain
import "strings"
type ApplyConfig struct {
Email string `json:"email"`
Access string `json:"access"`
@@ -16,6 +18,29 @@ type DeployConfig struct {
Config map[string]any `json:"config"`
}
// GetDomain returns the domain from the deploy config
// if the domain is a wildcard domain, and wildcard is true, return the wildcard domain
func (d *DeployConfig) GetDomain(wildcard ...bool) string {
if _, ok := d.Config["domain"]; !ok {
return ""
}
val, ok := d.Config["domain"].(string)
if !ok {
return ""
}
if !strings.HasPrefix(val, "*") {
return val
}
if len(wildcard) > 0 && wildcard[0] {
return val
}
return strings.TrimPrefix(val, "*")
}
type KV struct {
Key string `json:"key"`
Value string `json:"value"`