File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import (
4545// https://github.com/gatewayd-io/gatewayd/issues/324
4646var (
4747 enableTracing bool
48+ enableLinting bool
4849 collectorURL string
4950 enableSentry bool
5051 devMode bool
@@ -168,6 +169,22 @@ var runCmd = &cobra.Command{
168169 defer sentry .Recover ()
169170 }
170171
172+ // Lint the configuration files before loading them.
173+ if enableLinting {
174+ _ , span := otel .Tracer (config .TracerName ).Start (runCtx , "Lint configuration files" )
175+ defer span .End ()
176+
177+ // Lint the global configuration file and fail if it's not valid.
178+ if err := lintConfig (Global , globalConfigFile ); err != nil {
179+ log .Fatal (err )
180+ }
181+
182+ // Lint the plugin configuration file and fail if it's not valid.
183+ if err := lintConfig (Plugins , pluginConfigFile ); err != nil {
184+ log .Fatal (err )
185+ }
186+ }
187+
171188 // Load global and plugin configuration.
172189 conf = config .NewConfig (runCtx , globalConfigFile , pluginConfigFile )
173190 conf .InitConfig (runCtx )
@@ -775,4 +792,6 @@ func init() {
775792 & enableSentry , "sentry" , true , "Enable Sentry" )
776793 runCmd .Flags ().BoolVar (
777794 & enableUsageReport , "usage-report" , true , "Enable usage report" )
795+ runCmd .Flags ().BoolVar (
796+ & enableLinting , "lint" , true , "Enable linting of configuration files" )
778797}
You can’t perform that action at this time.
0 commit comments