Skip to content

Commit

Permalink
Merge pull request #117 from gchaincl/authenticator-binary
Browse files Browse the repository at this point in the history
Update authenticator name when checking its existence
  • Loading branch information
errordeveloper authored Aug 6, 2018
2 parents 111674b + 1497aca commit d36b558
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions pkg/utils/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,12 @@ func CheckKubectlVersion(env []string) error {
return nil
}

func CheckHeptioAuthenticatorAWS() error {
path, err := exec.LookPath("heptio-authenticator-aws")
if err == nil {
logger.Debug("heptio-authenticator-aws: %q", path)
} else {
return fmt.Errorf("heptio-authenticator-aws not installed")
}
return nil
}

func CheckAllCommands(kubeconfigPath string, isContextSet bool, contextName string, env []string) error {
if err := CheckKubectlVersion(env); err != nil {
return err
}

if err := CheckHeptioAuthenticatorAWS(); err != nil {
if err := checkAuthenticator(); err != nil {
return err
}

Expand Down Expand Up @@ -98,3 +88,17 @@ func CheckAllCommands(kubeconfigPath string, isContextSet bool, contextName stri

return nil
}

// checkAuthenticator checks for the authenticator binary existence.
func checkAuthenticator() error {
binaries := []string{"heptio-authenticator-aws", "aws-iam-authenticator"}
for _, bin := range binaries {
path, err := exec.LookPath(bin)
if err == nil {
// binary was found
logger.Debug("%s: %q", bin, path)
return nil
}
}
return fmt.Errorf("neither aws-iam-authenticator nor heptio-authenticator-aws are installed")
}

0 comments on commit d36b558

Please sign in to comment.