mirror of https://github.com/kubernetes/kops.git
Merge pull request #401 from justinsb/move_cloudprovider_not_set_message
Misc error handling tidying
This commit is contained in:
commit
a51effbbdd
|
|
@ -47,7 +47,7 @@ func init() {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
err := createCluster.Run(args)
|
err := createCluster.Run(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Exitf("%v", err)
|
exitWithError("%v", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -209,8 +209,7 @@ func (c *CreateClusterCmd) Run(args []string) error {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This is hard, because of the etcd cluster
|
// This is hard, because of the etcd cluster
|
||||||
glog.Errorf("Cannot change master-zones from the CLI")
|
return fmt.Errorf("Cannot change master-zones from the CLI")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,8 +297,7 @@ func (c *CreateClusterCmd) Run(args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster.SharedVPC() && cluster.Spec.NetworkCIDR == "" {
|
if cluster.SharedVPC() && cluster.Spec.NetworkCIDR == "" {
|
||||||
glog.Errorf("Must specify NetworkCIDR when VPC is set")
|
return fmt.Errorf("Must specify NetworkCIDR when VPC is set")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster.Spec.CloudProvider == "" {
|
if cluster.Spec.CloudProvider == "" {
|
||||||
|
|
@ -311,6 +309,9 @@ func (c *CreateClusterCmd) Run(args []string) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if cluster.Spec.CloudProvider == "" {
|
||||||
|
return fmt.Errorf("unable to infer CloudProvider from Zones (is there a typo in --zones?)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sshPublicKeys := make(map[string][]byte)
|
sshPublicKeys := make(map[string][]byte)
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,7 @@ func init() {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
err := exportKubecfgCommand.Run(args)
|
err := exportKubecfgCommand.Run(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
exitWithError(err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,7 @@ It allows you to create, destroy, upgrade and maintain clusters.`,
|
||||||
func Execute() {
|
func Execute() {
|
||||||
goflag.CommandLine.Parse([]string{})
|
goflag.CommandLine.Parse([]string{})
|
||||||
if err := rootCommand.cobraCommand.Execute(); err != nil {
|
if err := rootCommand.cobraCommand.Execute(); err != nil {
|
||||||
fmt.Println(err)
|
exitWithError(err)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ func (c *Cluster) Validate(strict bool) error {
|
||||||
// Check CloudProvider
|
// Check CloudProvider
|
||||||
{
|
{
|
||||||
if c.Spec.CloudProvider == "" {
|
if c.Spec.CloudProvider == "" {
|
||||||
return fmt.Errorf("unable to infer CloudProvider from Zones (is there a typo in --zones?)")
|
return fmt.Errorf("CloudProvider is not set")
|
||||||
}
|
}
|
||||||
if c.Spec.Kubelet != nil && c.Spec.Kubelet.CloudProvider != "" && c.Spec.Kubelet.CloudProvider != c.Spec.CloudProvider {
|
if c.Spec.Kubelet != nil && c.Spec.Kubelet.CloudProvider != "" && c.Spec.Kubelet.CloudProvider != c.Spec.CloudProvider {
|
||||||
return fmt.Errorf("Kubelet CloudProvider did not match cluster CloudProvider")
|
return fmt.Errorf("Kubelet CloudProvider did not match cluster CloudProvider")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue