From 346f8287ee370a59ce9848a4f436851af24e7aff Mon Sep 17 00:00:00 2001 From: pengbinbin1 Date: Mon, 22 Nov 2021 16:21:11 +0800 Subject: [PATCH] use const instead the string --- pkg/yurtctl/util/edgenode/util.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/yurtctl/util/edgenode/util.go b/pkg/yurtctl/util/edgenode/util.go index 3cc1e7d7934..8a190d216b8 100644 --- a/pkg/yurtctl/util/edgenode/util.go +++ b/pkg/yurtctl/util/edgenode/util.go @@ -32,6 +32,11 @@ import ( "k8s.io/klog" ) +const ( + NODE_NAME = "NODE_NAME" + KUBECONFIG = "KUBECONFIG" +) + // FileExists determines whether the file exists func FileExists(filename string) (bool, error) { if _, err := os.Stat(filename); os.IsExist(err) { @@ -106,7 +111,7 @@ func ReplaceRegularExpression(content string, replace map[string]string) string // in the configuration file or hostname func GetNodeName(kubeadmConfPath string) (string, error) { //1. from env NODE_NAME - nodename := os.Getenv("NODE_NAME") + nodename := os.Getenv(NODE_NAME) if nodename != "" { return nodename, nil } @@ -169,7 +174,7 @@ func PrepareKubeConfigPath(flags *pflag.FlagSet) (string, error) { } if kbCfgPath == "" { - kbCfgPath = os.Getenv("KUBECONFIG") + kbCfgPath = os.Getenv(KUBECONFIG) } if kbCfgPath == "" {