diff --git a/pkg/ctl/create/utils.go b/pkg/ctl/create/utils.go index 6d4e459aecd..15def9d55bc 100644 --- a/pkg/ctl/create/utils.go +++ b/pkg/ctl/create/utils.go @@ -81,7 +81,7 @@ func loadSSHKey(ng *api.NodeGroup, clusterName string, provider api.ClusterProvi logger.Info("using EC2 key pair %q", *sshConfig.PublicKeyName) // Local ssh key file - case utils.CheckFileExists(*sshConfig.PublicKeyPath) != nil: + case utils.CheckFileExists(*sshConfig.PublicKeyPath): keyName, err := ssh.LoadKeyFromFile(*sshConfig.PublicKeyPath, clusterName, ng.Name, provider) if err != nil { return err diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index b2bec396152..1822499ac8f 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -21,8 +21,8 @@ import ( // LoadKeyFromFile loads and imports a public SSH key from a file provided a path to that file. // returns the name of the key func LoadKeyFromFile(filePath, clusterName, ngName string, provider api.ClusterProvider) (string, error) { - if err := utils.CheckFileExists(filePath); err != nil { - return "", errors.Wrap(err, fmt.Sprintf("SSH public key file %q not found", filePath)) + if !utils.CheckFileExists(filePath) { + return "", fmt.Errorf("SSH public key file %q not found", filePath) } expandedPath := utils.ExpandPath(filePath) diff --git a/pkg/utils/file.go b/pkg/utils/file.go index 57e2995ff15..fbd221bd13c 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -20,12 +20,12 @@ func FileExists(path string) (bool, error) { } // CheckFileExists returns an error if the file doesn't exist -func CheckFileExists(filePath string) error { +func CheckFileExists(filePath string) bool { extendedPath := ExpandPath(filePath) if _, err := os.Stat(extendedPath); os.IsNotExist(err) { - return err + return false } - return nil + return true } // ExpandPath expands path with ~ notation