From 466f3acd71062bb595606d782843d747cbfe9b45 Mon Sep 17 00:00:00 2001 From: DanielGrunbergerCA Date: Mon, 11 Apr 2022 09:49:32 +0300 Subject: [PATCH] change to ge contextname --- cmd/submit/rbac.go | 2 +- cmd/submit/results.go | 2 +- core/cautils/customerloader.go | 12 ++++++------ core/core/download.go | 4 ++-- core/core/initutils.go | 2 +- core/core/scan.go | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/submit/rbac.go b/cmd/submit/rbac.go index 4a770cf4..e412f9ea 100644 --- a/cmd/submit/rbac.go +++ b/cmd/submit/rbac.go @@ -33,7 +33,7 @@ func getRBACCmd(ks meta.IKubescape, submitInfo *v1.Submit) *cobra.Command { } // list RBAC - rbacObjects := cautils.NewRBACObjects(rbacscanner.NewRbacScannerFromK8sAPI(k8s, clusterConfig.GetAccountID(), clusterConfig.GetClusterContext())) + rbacObjects := cautils.NewRBACObjects(rbacscanner.NewRbacScannerFromK8sAPI(k8s, clusterConfig.GetAccountID(), clusterConfig.GetContextName())) // submit resources r := reporterv1.NewReportEventReceiver(clusterConfig.GetConfigObj()) diff --git a/cmd/submit/results.go b/cmd/submit/results.go index 6896a870..b058c939 100644 --- a/cmd/submit/results.go +++ b/cmd/submit/results.go @@ -74,7 +74,7 @@ func getResultsCmd(ks meta.IKubescape, submitInfo *v1.Submit) *cobra.Command { logger.L().Error("failed setting account ID", helpers.Error(err)) } - resultsObjects := NewResultsObject(clusterConfig.GetAccountID(), clusterConfig.GetClusterContext(), args[0]) + resultsObjects := NewResultsObject(clusterConfig.GetAccountID(), clusterConfig.GetContextName(), args[0]) // submit resources var r reporter.IReport diff --git a/core/cautils/customerloader.go b/core/cautils/customerloader.go index 9c32a4b3..859ee58a 100644 --- a/core/cautils/customerloader.go +++ b/core/cautils/customerloader.go @@ -67,7 +67,7 @@ type ITenantConfig interface { DeleteCachedConfig() error // getters - GetClusterContext() string + GetContextName() string GetAccountID() string GetConfigObj() *ConfigObj // GetBackendAPI() getter.IBackend @@ -117,10 +117,10 @@ func NewLocalConfig( return lc } -func (lc *LocalConfig) GetConfigObj() *ConfigObj { return lc.configObj } -func (lc *LocalConfig) GetAccountID() string { return lc.configObj.AccountID } -func (lc *LocalConfig) GetClusterContext() string { return lc.configObj.ClusterName } -func (lc *LocalConfig) IsConfigFound() bool { return existsConfigFile() } +func (lc *LocalConfig) GetConfigObj() *ConfigObj { return lc.configObj } +func (lc *LocalConfig) GetAccountID() string { return lc.configObj.AccountID } +func (lc *LocalConfig) GetContextName() string { return lc.configObj.ClusterName } +func (lc *LocalConfig) IsConfigFound() bool { return existsConfigFile() } func (lc *LocalConfig) SetTenant() error { // ARMO tenant GUID @@ -268,7 +268,7 @@ func (c *ClusterConfig) DeleteCachedConfig() error { } return nil } -func (c *ClusterConfig) GetClusterContext() string { +func (c *ClusterConfig) GetContextName() string { return c.configObj.ClusterName } diff --git a/core/core/download.go b/core/core/download.go index 957fdaef..c73fe19d 100644 --- a/core/core/download.go +++ b/core/core/download.go @@ -83,7 +83,7 @@ func downloadConfigInputs(downloadInfo *metav1.DownloadInfo) error { tenant := getTenantConfig(downloadInfo.Account, "", getKubernetesApi()) controlsInputsGetter := getConfigInputsGetter(downloadInfo.Name, tenant.GetAccountID(), nil) - controlInputs, err := controlsInputsGetter.GetControlsInputs(tenant.GetClusterContext()) + controlInputs, err := controlsInputsGetter.GetControlsInputs(tenant.GetContextName()) if err != nil { return err } @@ -109,7 +109,7 @@ func downloadExceptions(downloadInfo *metav1.DownloadInfo) error { exceptionsGetter := getExceptionsGetter("") exceptions := []armotypes.PostureExceptionPolicy{} if tenant.GetAccountID() != "" { - exceptions, err = exceptionsGetter.GetExceptions(tenant.GetClusterContext()) + exceptions, err = exceptionsGetter.GetExceptions(tenant.GetContextName()) if err != nil { return err } diff --git a/core/core/initutils.go b/core/core/initutils.go index 894b91e9..49730725 100644 --- a/core/core/initutils.go +++ b/core/core/initutils.go @@ -43,7 +43,7 @@ func getExceptionsGetter(useExceptions string) getter.IExceptionsGetter { func getRBACHandler(tenantConfig cautils.ITenantConfig, k8s *k8sinterface.KubernetesApi, submit bool) *cautils.RBACObjects { if submit { - return cautils.NewRBACObjects(rbacscanner.NewRbacScannerFromK8sAPI(k8s, tenantConfig.GetAccountID(), tenantConfig.GetClusterContext())) + return cautils.NewRBACObjects(rbacscanner.NewRbacScannerFromK8sAPI(k8s, tenantConfig.GetAccountID(), tenantConfig.GetContextName())) } return nil } diff --git a/core/core/scan.go b/core/core/scan.go index 777c45a3..54da40c9 100644 --- a/core/core/scan.go +++ b/core/core/scan.go @@ -115,9 +115,9 @@ func (ks *Kubescape) Scan(scanInfo *cautils.ScanInfo) (*resultshandling.ResultsH interfaces := getInterfaces(scanInfo) - cautils.ClusterName = interfaces.tenantConfig.GetClusterContext() // TODO - Deprecated - cautils.CustomerGUID = interfaces.tenantConfig.GetAccountID() // TODO - Deprecated - interfaces.report.SetClusterName(interfaces.tenantConfig.GetClusterContext()) + cautils.ClusterName = interfaces.tenantConfig.GetContextName() // TODO - Deprecated + cautils.CustomerGUID = interfaces.tenantConfig.GetAccountID() // TODO - Deprecated + interfaces.report.SetClusterName(interfaces.tenantConfig.GetContextName()) interfaces.report.SetCustomerGUID(interfaces.tenantConfig.GetAccountID()) downloadReleasedPolicy := getter.NewDownloadReleasedPolicy() // download config inputs from github release @@ -149,7 +149,7 @@ func (ks *Kubescape) Scan(scanInfo *cautils.ScanInfo) (*resultshandling.ResultsH } // ========================= opa testing ===================== - deps := resources.NewRegoDependenciesData(k8sinterface.GetK8sConfig(), interfaces.tenantConfig.GetClusterContext()) + deps := resources.NewRegoDependenciesData(k8sinterface.GetK8sConfig(), interfaces.tenantConfig.GetContextName()) reportResults := opaprocessor.NewOPAProcessor(scanData, deps) if err := reportResults.ProcessRulesListenner(); err != nil { // TODO - do something