Skip to content

Commit

Permalink
use const instead the string (openyurtio#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengbinbin1 authored Nov 22, 2021
1 parent 4cd3103 commit 4be66e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/yurtctl/util/edgenode/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -169,7 +174,7 @@ func PrepareKubeConfigPath(flags *pflag.FlagSet) (string, error) {
}

if kbCfgPath == "" {
kbCfgPath = os.Getenv("KUBECONFIG")
kbCfgPath = os.Getenv(KUBECONFIG)
}

if kbCfgPath == "" {
Expand Down

0 comments on commit 4be66e9

Please sign in to comment.