diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 9baeface2b..b9bef2dd45 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -47,7 +47,7 @@ func init() { Run: func(cmd *cobra.Command, args []string) { err := createCluster.Run(args) if err != nil { - glog.Exitf("%v", err) + exitWithError("%v", err) } }, } @@ -209,8 +209,7 @@ func (c *CreateClusterCmd) Run(args []string) error { } } else { // This is hard, because of the etcd cluster - glog.Errorf("Cannot change master-zones from the CLI") - os.Exit(1) + return fmt.Errorf("Cannot change master-zones from the CLI") } } @@ -298,8 +297,7 @@ func (c *CreateClusterCmd) Run(args []string) error { } if cluster.SharedVPC() && cluster.Spec.NetworkCIDR == "" { - glog.Errorf("Must specify NetworkCIDR when VPC is set") - os.Exit(1) + return fmt.Errorf("Must specify NetworkCIDR when VPC is set") } if cluster.Spec.CloudProvider == "" { diff --git a/cmd/kops/export_kubecfg.go b/cmd/kops/export_kubecfg.go index 9706a09430..82a3e5cb85 100644 --- a/cmd/kops/export_kubecfg.go +++ b/cmd/kops/export_kubecfg.go @@ -24,8 +24,7 @@ func init() { Run: func(cmd *cobra.Command, args []string) { err := exportKubecfgCommand.Run(args) if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) + exitWithError(err) } }, } diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 9ca920f634..dfe8eaf26b 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -37,8 +37,7 @@ It allows you to create, destroy, upgrade and maintain clusters.`, func Execute() { goflag.CommandLine.Parse([]string{}) if err := rootCommand.cobraCommand.Execute(); err != nil { - fmt.Println(err) - os.Exit(-1) + exitWithError(err) } }