Migrated to cobra for command handling and viper for config handling
This commit is contained in:
@@ -96,18 +96,9 @@ type StoredCertMeta struct {
|
||||
// - Cloudflare DNS-01 only
|
||||
func NewACMEManager() (*ACMEManager, error) {
|
||||
// Pull effective (main-only) certificate settings.
|
||||
email, err := config.GetAsStringErr("Certificates.email")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dataRoot, err := config.GetAsStringErr("Certificates.data_root")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caDirURL, err := config.GetAsStringErr("Certificates.ca_dir_url")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
email := config.GetString("Certificates.email")
|
||||
dataRoot := config.GetString("Certificates.data_root")
|
||||
caDirURL := config.GetString("Certificates.ca_dir_url")
|
||||
|
||||
// Build manager paths
|
||||
mgr := &ACMEManager{
|
||||
@@ -246,51 +237,31 @@ func (m *ACMEManager) GetCertPaths(domainKey string) (certPEM, keyPEM string) {
|
||||
// ---------------------------------------------
|
||||
|
||||
func buildDomainRuntimeConfig(domainKey string) (*DomainRuntimeConfig, error) {
|
||||
domainCfg, exists := getDomainConfig(domainKey)
|
||||
domainCfg, exists := domainStore.Get(domainKey)
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("domain config not found for %q", domainKey)
|
||||
}
|
||||
|
||||
domainName, err := domainCfg.GetAsStringErr("Domain.domain_name")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
domainName := domainCfg.GetString("Domain.domain_name")
|
||||
|
||||
email, err := config.GetAsStringErr("Certificates.email")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
email := config.GetString("Certificates.email")
|
||||
|
||||
// domain override data_root can be blank -> main fallback
|
||||
dataRoot, err := getEffectiveString(domainCfg, "Certificates.data_root")
|
||||
dataRoot, err := EffectiveString(domainCfg, "Certificates.data_root")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
caDirURL, err := config.GetAsStringErr("Certificates.ca_dir_url")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
caDirURL := config.GetString("Certificates.ca_dir_url")
|
||||
|
||||
expiry, err := domainCfg.GetAsIntErr("Certificates.expiry")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expiry := domainCfg.GetInt("Certificates.expiry")
|
||||
|
||||
renewPeriod, err := domainCfg.GetAsIntErr("Certificates.renew_period")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
renewPeriod := domainCfg.GetInt("Certificates.renew_period")
|
||||
|
||||
requestMethod := ""
|
||||
if k, err := domainCfg.GetKey("Certificates.request_method"); err == nil && k != nil {
|
||||
requestMethod = strings.TrimSpace(k.String())
|
||||
}
|
||||
requestMethod := domainCfg.GetString("Certificates.request_method")
|
||||
|
||||
subdomains := []string{}
|
||||
if k, err := domainCfg.GetKey("Certificates.subdomains"); err == nil && k != nil {
|
||||
subdomains = parseCSVLines(k.String())
|
||||
}
|
||||
subdomains := domainCfg.GetString("Certificates.subdomains")
|
||||
subdomainArray := parseCSVLines(subdomains)
|
||||
|
||||
return &DomainRuntimeConfig{
|
||||
DomainName: domainName,
|
||||
@@ -300,7 +271,7 @@ func buildDomainRuntimeConfig(domainKey string) (*DomainRuntimeConfig, error) {
|
||||
ExpiryDays: expiry,
|
||||
RenewPeriod: renewPeriod,
|
||||
RequestMethod: requestMethod,
|
||||
Subdomains: subdomains,
|
||||
Subdomains: subdomainArray,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -377,14 +348,8 @@ func buildDomainList(baseDomain string, subs []string) []string {
|
||||
func setCloudflareEnvFromMainConfig() (restore func(), err error) {
|
||||
// Your current defaults show legacy email + API key fields.
|
||||
// Prefer API tokens in the future if you add them. Cloudflare provider supports both styles. :contentReference[oaicite:3]{index=3}
|
||||
cfEmail, err := config.GetAsStringErr("Cloudflare.cf_email")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfAPIKey, err := config.GetAsStringErr("Cloudflare.cf_api_key")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfEmail := config.GetString("Cloudflare.cf_email")
|
||||
cfAPIKey := config.GetString("Cloudflare.cf_api_key")
|
||||
|
||||
// Save prior env values so we can restore them after provider creation.
|
||||
prevEmail, hadEmail := os.LookupEnv("CLOUDFLARE_EMAIL")
|
||||
|
||||
Reference in New Issue
Block a user