From a2ef08fd05ff2c94e454103e3f87bb59085a15d0 Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Mon, 22 Jul 2024 18:00:13 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20support=20MONDOO=5FOUTPUT=20as?= =?UTF-8?q?=20env=20variable=20(#1377)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cnspec/cmd/scan.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/cnspec/cmd/scan.go b/apps/cnspec/cmd/scan.go index 2285c809..5432b3e9 100644 --- a/apps/cnspec/cmd/scan.go +++ b/apps/cnspec/cmd/scan.go @@ -129,6 +129,7 @@ To manually configure a policy, use this: _ = viper.BindPFlag("annotations", cmd.Flags().Lookup("annotation")) _ = viper.BindPFlag("props", cmd.Flags().Lookup("props")) + _ = viper.BindPFlag("json", cmd.Flags().Lookup("json")) _ = viper.BindPFlag("output", cmd.Flags().Lookup("output")) if err := viper.BindPFlag("output-target", cmd.Flags().Lookup("output-target")); err != nil { return err @@ -279,14 +280,14 @@ func getCobraScanConfig(cmd *cobra.Command, runtime *providers.Runtime, cliRes * // if users want to get more information on available output options, // print them before executing the scan - output, _ := cmd.Flags().GetString("output") + output := viper.GetString("output") if output == "help" { fmt.Println(reporter.AllAvailableOptions()) os.Exit(0) } // --json takes precedence - if ok, _ := cmd.Flags().GetBool("json"); ok { + if ok := viper.GetBool("json"); ok { output = "json" } conf.OutputFormat = output