summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorY.Horie <u5.horie@gmail.com>2023-01-28 13:31:37 +0900
committerGitHub <noreply@github.com>2023-01-27 23:31:37 -0500
commitd73660f7c338cf4d12ba82c07e14df7f53593ea5 (patch)
treedfb02b939bb231a2e6f7ae3545a5c235c27316f8 /caddyconfig
parent7f2a93e6c36ceec9e007baeedeb594ab0dc43a71 (diff)
httpcaddyfile: Add persist_config global option (#5339)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Diffstat (limited to 'caddyconfig')
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go11
-rw-r--r--caddyconfig/httpcaddyfile/options.go16
2 files changed, 27 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index 43d756f..50e98ac 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -286,6 +286,17 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
if adminConfig, ok := options["admin"].(*caddy.AdminConfig); ok && adminConfig != nil {
cfg.Admin = adminConfig
}
+
+ if pc, ok := options["persist_config"].(string); ok && pc == "off" {
+ if cfg.Admin == nil {
+ cfg.Admin = new(caddy.AdminConfig)
+ }
+ if cfg.Admin.Config == nil {
+ cfg.Admin.Config = new(caddy.ConfigSettings)
+ }
+ cfg.Admin.Config.Persist = new(bool)
+ }
+
if len(customLogs) > 0 {
if cfg.Logging == nil {
cfg.Logging = &caddy.Logging{
diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go
index 1775c93..4e5212b 100644
--- a/caddyconfig/httpcaddyfile/options.go
+++ b/caddyconfig/httpcaddyfile/options.go
@@ -54,6 +54,7 @@ func init() {
RegisterGlobalOption("ocsp_stapling", parseOCSPStaplingOptions)
RegisterGlobalOption("log", parseLogOptions)
RegisterGlobalOption("preferred_chains", parseOptPreferredChains)
+ RegisterGlobalOption("persist_config", parseOptPersistConfig)
}
func parseOptTrue(d *caddyfile.Dispenser, _ any) (any, error) { return true, nil }
@@ -386,6 +387,21 @@ func parseOptOnDemand(d *caddyfile.Dispenser, _ any) (any, error) {
return ond, nil
}
+func parseOptPersistConfig(d *caddyfile.Dispenser, _ any) (any, error) {
+ d.Next() // consume parameter name
+ if !d.Next() {
+ return "", d.ArgErr()
+ }
+ val := d.Val()
+ if d.Next() {
+ return "", d.ArgErr()
+ }
+ if val != "off" {
+ return "", d.Errf("persist_config must be 'off'")
+ }
+ return val, nil
+}
+
func parseOptAutoHTTPS(d *caddyfile.Dispenser, _ any) (any, error) {
d.Next() // consume parameter name
if !d.Next() {