Don't error out when no kubernetes client is found

This commit is contained in:
Ian Howell 2019-05-07 13:02:18 -05:00
parent 7a34fd98d9
commit 85924f6381
2 changed files with 6 additions and 2 deletions

View File

@ -41,8 +41,9 @@ func NewRootCmd(out io.Writer, client *kube.Client, args []string) (*cobra.Comma
// Execute runs the base airshipctl command
func Execute(out io.Writer) {
client, err := kube.NewForConfig(settings.KubeConfigFilePath)
osExitIfError(out, err)
// TODO(howell): Fix this unused error
client, _ := kube.NewForConfig(settings.KubeConfigFilePath)
rootCmd, err := NewRootCmd(out, client, os.Args[1:])
osExitIfError(out, err)
osExitIfError(out, rootCmd.Execute())

View File

@ -45,6 +45,9 @@ func clientVersion() string {
}
func kubeVersion(client *kube.Client) (string, error) {
if client == nil {
return "could not connect to a kubernetes cluster", nil
}
version, err := client.Discovery().ServerVersion()
if err != nil {
return "", err