From 063d3ee3138e142d53c1e252a335ecafbf08986c Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Thu, 6 Oct 2022 11:04:05 +0300 Subject: [PATCH] Adopt custom cluster name (#862) * change user to ks * update logs * host scanner with fixed version * testing gh actions * testing gh actions * Workflow call testing (#7) * testing gh actions * testing gh actions * remove deps * build multi platforms * workflow_call testing * adding workflow-call-testing branch name * specify URL * adding org name * adding workflows * cleaning from unused branches * Adopt custom cluster name --- core/cautils/customerloader.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/core/cautils/customerloader.go b/core/cautils/customerloader.go index 44df78cb..5548ce5c 100644 --- a/core/cautils/customerloader.go +++ b/core/cautils/customerloader.go @@ -106,7 +106,7 @@ func NewLocalConfig( // 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) + lc.configObj.ClusterName = AdoptClusterName(customClusterName) } else if clusterName != "" { lc.configObj.ClusterName = AdoptClusterName(clusterName) // override config clusterName } @@ -216,7 +216,7 @@ func NewClusterConfig(k8s *k8sinterface.KubernetesApi, backendAPI getter.IBacken // If a custom cluster name is provided then set that name, else use the cluster's original name if customClusterName != "" { - c.configObj.ClusterName = AdoptCustomClusterName(customClusterName) + c.configObj.ClusterName = AdoptClusterName(customClusterName) } else if clusterName != "" { c.configObj.ClusterName = AdoptClusterName(clusterName) // override config clusterName } @@ -474,19 +474,6 @@ func DeleteConfigFile() error { return os.Remove(ConfigFileFullPath()) } -// To check if the custom cluster name is valid: -func AdoptCustomClusterName(customClusterName string) string { - is_alphanumeric := regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(customClusterName) - - // Check it does not contain special-characters - if is_alphanumeric == false { - logger.L().Fatal("custom cluster name cannot contain special characters") - } else if len(customClusterName) >= 256 { // Check it contains less than 256 characters - logger.L().Fatal("custom cluster name cannot contain more than 255 characters") - } - return customClusterName -} - func AdoptClusterName(clusterName string) string { re, err := regexp.Compile(`[^\w]+`) if err != nil {