From e94264168d7d826f8a23068d8403469f5dc8a24c Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Mon, 16 Oct 2023 10:11:24 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20exit=20if=20annotatio?= =?UTF-8?q?ns=20not=20defined=20in=20scan/vuln=20cmd.=20(#842)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ๐Ÿ› Do not exit if annotations not defined in scan/vuln cmd. * ๐Ÿงน add comment why we need no error check for annotations --------- Co-authored-by: Christoph Hartmann --- apps/cnspec/cmd/scan.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/cnspec/cmd/scan.go b/apps/cnspec/cmd/scan.go index d16164e6..026cb480 100644 --- a/apps/cnspec/cmd/scan.go +++ b/apps/cnspec/cmd/scan.go @@ -215,11 +215,8 @@ func getCobraScanConfig(cmd *cobra.Command, runtime *providers.Runtime, cliRes * log.Fatal().Err(err).Msg("failed to parse inventory") } - annotations, err := cmd.Flags().GetStringToString("annotation") - if err != nil { - log.Fatal().Err(err).Msg("failed to parse annotations") - } - + // annotations are user-added, editable labels for assets and are optional, therefore we do not need to check for err + annotations, _ := cmd.Flags().GetStringToString("annotation") // merge the config and the user-provided annotations with the latter having precedence optAnnotations := opts.Annotations if optAnnotations == nil {