summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-03-09 00:09:15 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-03-09 00:09:15 -0600
commit99d34f1c1d6a785104252303c9c7744373052342 (patch)
tree003c75c3a69f8e3a8870f5a0c2158275ee47cc91
parent36a6c7daf0f45353efe860e254aa148b7574b04e (diff)
cmd: Use loadConfig() for validate as run, start, and reload do
-rw-r--r--cmd/commandfuncs.go29
1 files changed, 2 insertions, 27 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 8ab9099..12d2586 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -492,35 +492,10 @@ func cmdValidateConfig(fl Flags) (int, error) {
validateCmdConfigFlag := fl.String("config")
validateCmdAdapterFlag := fl.String("adapter")
- input, err := ioutil.ReadFile(validateCmdConfigFlag)
+ input, _, err := loadConfig(validateCmdConfigFlag, validateCmdAdapterFlag)
if err != nil {
- return caddy.ExitCodeFailedStartup,
- fmt.Errorf("reading input file: %v", err)
- }
-
- if validateCmdAdapterFlag != "" {
- cfgAdapter := caddyconfig.GetAdapter(validateCmdAdapterFlag)
- if cfgAdapter == nil {
- return caddy.ExitCodeFailedStartup,
- fmt.Errorf("unrecognized config adapter: %s", validateCmdAdapterFlag)
- }
-
- adaptedConfig, warnings, err := cfgAdapter.Adapt(input, nil)
- if err != nil {
- return caddy.ExitCodeFailedStartup, err
- }
- // print warnings to stderr
- for _, warn := range warnings {
- msg := warn.Message
- if warn.Directive != "" {
- msg = fmt.Sprintf("%s: %s", warn.Directive, warn.Message)
- }
- fmt.Fprintf(os.Stderr, "[WARNING][%s] %s:%d: %s\n", validateCmdAdapterFlag, warn.File, warn.Line, msg)
- }
-
- input = adaptedConfig
+ return caddy.ExitCodeFailedStartup, err
}
-
input = caddy.RemoveMetaFields(input)
var cfg *caddy.Config