diff options
author | Amis Shokoohi <[email protected]> | 2023-02-01 00:57:35 +0330 |
---|---|---|
committer | GitHub <[email protected]> | 2023-01-31 16:27:35 -0500 |
commit | 94b8d56096b2581d6739b057655e7b895c8fd3bb (patch) | |
tree | 8a3b32ec744afe3f174c6ea91c7e6803e0e58009 /cmd/commandfuncs.go | |
parent | 8c0b49bf039bc0b6ab72b44ef0e1e6587c76ad2b (diff) | |
download | caddy-94b8d56096b2581d6739b057655e7b895c8fd3bb.tar.gz caddy-94b8d56096b2581d6739b057655e7b895c8fd3bb.zip |
cmd: Add `--envfile` flag to `validate` command (#5350)
Fixes https://github.com/caddyserver/caddy/issues/5346
Diffstat (limited to 'cmd/commandfuncs.go')
-rw-r--r-- | cmd/commandfuncs.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index c5264ed41..09accd0d3 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -506,6 +506,15 @@ func cmdAdaptConfig(fl Flags) (int, error) { func cmdValidateConfig(fl Flags) (int, error) { validateCmdConfigFlag := fl.String("config") validateCmdAdapterFlag := fl.String("adapter") + runCmdLoadEnvfileFlag := fl.String("envfile") + + // load all additional envs as soon as possible + if runCmdLoadEnvfileFlag != "" { + if err := loadEnvFromFile(runCmdLoadEnvfileFlag); err != nil { + return caddy.ExitCodeFailedStartup, + fmt.Errorf("loading additional environment variables: %v", err) + } + } input, _, err := LoadConfig(validateCmdConfigFlag, validateCmdAdapterFlag) if err != nil { |