Skip to content

Commit

Permalink
Avoid shaddowing of global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Jun 21, 2018
1 parent 29ab9d1 commit b01d17e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/utils/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import (
"github.com/weaveworks/launcher/pkg/kubectl"
)

var kubectlPath string

func CheckKubectlVersion() error {
func CheckKubectlVersion() (string, error) {
ktl := &kubectl.LocalClient{}
kubectlPath, err := ktl.LookPath()
if err != nil {
return fmt.Errorf("kubectl not found, v1.10.0 or newever is required")
return "", fmt.Errorf("kubectl not found, v1.10.0 or newever is required")
}
logger.Debug("kubectl: %q", kubectlPath)

Expand All @@ -27,12 +25,12 @@ func CheckKubectlVersion() error {

version, err := semver.Parse(strings.TrimLeft(clientVersion, "v"))
if err != nil {
return errors.Wrapf(err, "parsing kubectl version string %q", version)
return "", errors.Wrapf(err, "parsing kubectl version string %q", version)
}
if version.Major == 1 && version.Minor < 10 {
return fmt.Errorf("kubectl version %s was found at %q, minimum required version to use EKS is v1.10.0", clientVersion, kubectlPath)
return "", fmt.Errorf("kubectl version %s was found at %q, minimum required version to use EKS is v1.10.0", clientVersion, kubectlPath)
}
return nil
return kubectlPath, nil
}

func CheckHeptioAuthenticatorAWS() error {
Expand All @@ -46,7 +44,8 @@ func CheckHeptioAuthenticatorAWS() error {
}

func CheckAllCommands(kubeconfigPath string) error {
if err := CheckKubectlVersion(); err != nil {
kubectlPath, err := CheckKubectlVersion()
if err != nil {
return err
}

Expand Down

0 comments on commit b01d17e

Please sign in to comment.