diff --git a/cmd/root.go b/cmd/root.go index 6b648628..a025b2ac 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "slices" logconfig "github.com/kubewarden/audit-scanner/internal/log" "github.com/kubewarden/audit-scanner/internal/policies" @@ -30,7 +31,7 @@ var level logconfig.Level var logFormat string // list of supported format of logs to stdout & stderr -var logFormatSupportedFormats = [1]string{"json"} +var logFormatSupportedFormats = []string{"json"} // list of namespaces to be skipped from scan var skippedNs []string @@ -72,10 +73,7 @@ There will be a ClusterPolicyReport with results for cluster-wide resources.`, if err != nil { return err } - switch logFormat { - // TODO use slices package in go 1.21 - case "json": // skip - default: + if slices.Contains(logFormatSupportedFormats, logFormat) { return fmt.Errorf("passed log-fmt not supported. Please select one of the supported formats: %v", logFormatSupportedFormats) }