mirror of https://github.com/kubernetes/kops.git
Merge pull request #3038 from justinsb/fix_3011
Automatic merge from submit-queue Handle the case where GetCluster returns nil
This commit is contained in:
commit
681c74e9a0
|
@ -176,6 +176,10 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
|
|||
return fmt.Errorf("error querying cluster %q: %v", clusterName, err)
|
||||
}
|
||||
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q not found", clusterName)
|
||||
}
|
||||
|
||||
_, err = clientset.InstanceGroupsFor(cluster).Create(v)
|
||||
if err != nil {
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
|
|
|
@ -90,6 +90,10 @@ func RunGetInstanceGroups(options *GetInstanceGroupsOptions, args []string) erro
|
|||
return fmt.Errorf("error fetching cluster %q: %v", clusterName, err)
|
||||
}
|
||||
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q was not found", clusterName)
|
||||
}
|
||||
|
||||
list, err := clientset.InstanceGroupsFor(cluster).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -120,6 +120,9 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *ReplaceOp
|
|||
if err != nil {
|
||||
return fmt.Errorf("error fetching cluster %q: %v", clusterName, err)
|
||||
}
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q not found", clusterName)
|
||||
}
|
||||
_, err = clientset.InstanceGroupsFor(cluster).Update(v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error replacing instanceGroup: %v", err)
|
||||
|
|
|
@ -104,6 +104,10 @@ func RunToolboxConvertImported(f *util.Factory, out io.Writer, options *ToolboxC
|
|||
return err
|
||||
}
|
||||
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q not found", options.ClusterName)
|
||||
}
|
||||
|
||||
list, err := clientset.InstanceGroupsFor(cluster).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -71,6 +71,9 @@ func (o *ApplyFederationOperation) FindKubecfg() (*kubeconfig.KubeconfigBuilder,
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading cluster %q: %v", controller, err)
|
||||
}
|
||||
if cluster == nil {
|
||||
return nil, fmt.Errorf("cluster %q not found", controller)
|
||||
}
|
||||
|
||||
context, err := o.federationContextForCluster(cluster)
|
||||
if err != nil {
|
||||
|
@ -120,6 +123,9 @@ func (o *ApplyFederationOperation) Run() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("error reading cluster %q: %v", controller, err)
|
||||
}
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q not found", controller)
|
||||
}
|
||||
|
||||
context, err := o.federationContextForCluster(cluster)
|
||||
if err != nil {
|
||||
|
@ -154,6 +160,9 @@ func (o *ApplyFederationOperation) Run() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("error reading cluster %q: %v", member, err)
|
||||
}
|
||||
if cluster == nil {
|
||||
return fmt.Errorf("cluster %q not found", member)
|
||||
}
|
||||
|
||||
clusterName := strings.Replace(cluster.Name, ".", "-", -1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue