From 4351099e79647c544497adea1fa434ed182d71a6 Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Sun, 18 Sep 2022 11:41:28 +0300 Subject: [PATCH] Fix merge conflict --- cmd/scan/scan.go | 2 +- core/cautils/customerloader.go | 9 ++++----- core/cautils/scaninfo.go | 8 +------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmd/scan/scan.go b/cmd/scan/scan.go index 91fc68f3..b29ea578 100644 --- a/cmd/scan/scan.go +++ b/cmd/scan/scan.go @@ -90,7 +90,7 @@ func GetScanCommand(ks meta.IKubescape) *cobra.Command { scanCmd.PersistentFlags().StringSliceVar(&scanInfo.UseFrom, "use-from", nil, "Load local policy object from specified path. If not used will download latest") scanCmd.PersistentFlags().BoolVarP(&scanInfo.Submit, "submit", "", false, "Send the scan results to ARMO management portal where you can see the results in a user-friendly UI, choose your preferred compliance framework, check risk results history and trends, manage exceptions, get remediation recommendations and much more. By default the results are not submitted") scanCmd.PersistentFlags().StringVar(&scanInfo.HostSensorYamlPath, "host-scan-yaml", "", "Override default host scanner DaemonSet. Use this flag cautiously") - scanCmd.PersistentFlags().StringVar(&scanInfo.FormatVersion, "format-version", "v1", "Output object can be differnet between versions, this is for maintaining backward and forward compatibility. Supported:'v1'/'v2'") + scanCmd.PersistentFlags().StringVar(&scanInfo.FormatVersion, "format-version", "v1", "Output object can be different between versions, this is for maintaining backward and forward compatibility. Supported:'v1'/'v2'") scanCmd.PersistentFlags().StringVar(&scanInfo.CustomClusterName, "cluster-name", "", "Set the custom name of the cluster. Not same as the kube-context flag") // Deprecated flags - remove 1.May.2022 diff --git a/core/cautils/customerloader.go b/core/cautils/customerloader.go index 9e4f789d..4a831521 100644 --- a/core/cautils/customerloader.go +++ b/core/cautils/customerloader.go @@ -7,7 +7,6 @@ import ( "os" "regexp" "strings" - "regexp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -105,10 +104,10 @@ func NewLocalConfig( updateCredentials(lc.configObj, credentials) - // If a custom cluster name is provided then set that name, else use the cluster's original name - if customClusterName != ""{ + // If a custom cluster name is provided then set that name, else use the cluster's original name + if customClusterName != "" { lc.configObj.ClusterName = AdoptCustomClusterName(customClusterName) - }else if clusterName != "" { + } else if clusterName != "" { lc.configObj.ClusterName = AdoptClusterName(clusterName) // override config clusterName } @@ -476,7 +475,7 @@ func DeleteConfigFile() error { } // To check if the custom cluster name is valid: -func AdoptCustomClusterName(customClusterName string) string{ +func AdoptCustomClusterName(customClusterName string) string { is_alphanumeric := regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(customClusterName) // Check it does not contain special-characters diff --git a/core/cautils/scaninfo.go b/core/cautils/scaninfo.go index 7f856ee9..059ff3ef 100644 --- a/core/cautils/scaninfo.go +++ b/core/cautils/scaninfo.go @@ -112,6 +112,7 @@ type ScanInfo struct { Format string // Format results (table, json, junit ...) Output string // Store results in an output file, Output file name FormatVersion string // Output object can be differnet between versions, this is for testing and backward compatibility + CustomClusterName string // Set the custom name of the cluster ExcludedNamespaces string // used for host scanner namespace IncludeNamespaces string // InputPatterns []string // Yaml files input patterns @@ -210,13 +211,6 @@ func (scanInfo *ScanInfo) setOutputFile() { } } -// func (scanInfo *ScanInfo) GetScanningEnvironment() string { -// if len(scanInfo.InputPatterns) != 0 { -// return ScanLocalFiles -// } -// return ScanCluster -// } - func (scanInfo *ScanInfo) SetPolicyIdentifiers(policies []string, kind apisv1.NotificationPolicyKind) { for _, policy := range policies { if !scanInfo.contains(policy) {