16808: add strict mode to arvados-server config-check
authorWard Vandewege <ward@curii.com>
Thu, 10 Sep 2020 16:55:13 +0000 (12:55 -0400)
committerWard Vandewege <ward@curii.com>
Thu, 10 Sep 2020 16:55:13 +0000 (12:55 -0400)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/config/cmd.go
lib/config/load.go

index 1ea0883ac84730738981cb499fe874983fda6ca5..dd6f1f98c577527c1cfb84ffdb2b05ef314d635b 100644 (file)
@@ -148,15 +148,21 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
                fmt.Fprintln(stdout, "Your configuration is relying on deprecated entries. Suggest making the following changes.")
                stdout.Write(diff)
                err = nil
-               return 1
+               if loader.Strict {
+                       return 1
+               }
        } else if len(diff) > 0 {
                fmt.Fprintf(stderr, "Unexpected diff output:\n%s", diff)
-               return 1
+               if loader.Strict {
+                       return 1
+               }
        } else if err != nil {
                return 1
        }
        if logbuf.Len() > 0 {
-               return 1
+               if loader.Strict {
+                       return 1
+               }
        }
 
        if problems {
index be6181bbe9bbc033cd9241cc14a8eca36ed23610..3359dc567ba17ab31fc4d246724bebbd6ce410af 100644 (file)
@@ -29,6 +29,7 @@ type Loader struct {
        SkipDeprecated bool // Don't load deprecated config keys
        SkipLegacy     bool // Don't load legacy config files
        SkipAPICalls   bool // Don't do checks that call RailsAPI/controller
+       Strict         bool // In config-check, any warnings or diff is non-empty will result in a non-zero exit code
 
        Path                    string
        KeepstorePath           string
@@ -73,6 +74,7 @@ func (ldr *Loader) SetupFlags(flagset *flag.FlagSet) {
                flagset.StringVar(&ldr.GitHttpdPath, "legacy-git-httpd-config", defaultGitHttpdConfigPath, "Legacy arv-git-httpd configuration `file`")
                flagset.StringVar(&ldr.KeepBalancePath, "legacy-keepbalance-config", defaultKeepBalanceConfigPath, "Legacy keep-balance configuration `file`")
                flagset.BoolVar(&ldr.SkipLegacy, "skip-legacy", false, "Don't load legacy config files")
+               flagset.BoolVar(&ldr.Strict, "strict", true, "Strict validation of configuration file (warnings result in non-zero exit code)")
        }
 }