From 60c8f953559c359a61ddc72d340fc319f81e7f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Cuadrado=20Juan?= Date: Wed, 6 Sep 2023 15:12:57 +0200 Subject: [PATCH] refactor: Use `slices` package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: VĂ­ctor Cuadrado Juan --- cmd/root.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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) }