Skip to content

Commit a7143dc

Browse files
committed
fix issue with the providers_url passed through --config not being used
1 parent 8bdbc32 commit a7143dc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cli/config/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ func Init(rootCmd *cobra.Command) {
4949
})
5050
// persistent flags are global for the application
5151
rootCmd.PersistentFlags().StringVar(&UserProvidedPath, "config", "", "Set config file path (default $HOME/.config/mondoo/mondoo.yml)")
52+
53+
// We need to parse the flags really early in the process, so that
54+
// the config path is set before we initialize viper. This is because
55+
// the providers configuration needs to be available before the rootCmd
56+
// is executed as it does things like tries to download a provider if its missing
57+
// See AttachCLIs in cli/providers/providers.go
58+
if err := rootCmd.ParseFlags(os.Args); err != nil {
59+
log.Error().Err(err).Msg("could not parse flags")
60+
}
5261
}
5362

5463
func InitViperConfig() {
@@ -227,6 +236,11 @@ type CommonOpts struct {
227236

228237
// annotations that will be applied to all assets
229238
Annotations map[string]string `json:"annotations,omitempty" mapstructure:"annotations"`
239+
240+
// ProvidersURL is the URL where providers are downloaded from
241+
// if not set, the default Mondoo provider URL is used
242+
// This can be a custom URL for an internal provider registry
243+
ProvidersURL string `json:"providers_url,omitempty" mapstructure:"providers_url"`
230244
}
231245

232246
// Workload Identity Federation

0 commit comments

Comments
 (0)