`kops get ...` should exit with non-zero if the resource don't exist

Without this change, `kops get --name non-existing-cluster` will
exit with a status of `0`, which makes it difficult to check if
a cluster (and other resources) exist in a shell script.
This commit is contained in:
Erick Tryzelaar 2017-10-11 16:04:06 -07:00
parent f14b5a564a
commit 5a89dd113c
5 changed files with 5 additions and 11 deletions

View File

@ -125,8 +125,7 @@ func RunGet(context Factory, out io.Writer, options *GetOptions) error {
} }
if cluster == nil { if cluster == nil {
fmt.Fprintf(os.Stderr, "No cluster found\n") return fmt.Errorf("No cluster found")
return nil
} }
clusterList := &api.ClusterList{} clusterList := &api.ClusterList{}

View File

@ -133,8 +133,7 @@ func RunGetClusters(context Factory, out io.Writer, options *GetClusterOptions)
} }
if len(clusters) == 0 { if len(clusters) == 0 {
fmt.Fprintf(os.Stderr, "No clusters found\n") return fmt.Errorf("No clusters found")
return nil
} }
if options.FullSpec { if options.FullSpec {

View File

@ -83,8 +83,7 @@ func RunGetFederations(context Factory, out io.Writer, options *GetFederationOpt
federations = append(federations, &list.Items[i]) federations = append(federations, &list.Items[i])
} }
if len(federations) == 0 { if len(federations) == 0 {
fmt.Fprintf(out, "No federations found\n") return fmt.Errorf("No federations found")
return nil
} }
switch options.output { switch options.output {

View File

@ -109,8 +109,7 @@ func RunGetInstanceGroups(options *GetInstanceGroupsOptions, args []string) erro
} }
if len(instancegroups) == 0 { if len(instancegroups) == 0 {
fmt.Fprintf(os.Stderr, "No InstanceGroup objects found\n") return fmt.Errorf("No InstanceGroup objects found")
return nil
} }
switch options.output { switch options.output {

View File

@ -167,9 +167,7 @@ func RunGetSecrets(options *GetSecretsOptions, args []string) error {
} }
if len(items) == 0 { if len(items) == 0 {
fmt.Fprintf(os.Stderr, "No secrets found\n") return fmt.Errorf("No secrets found")
return nil
} }
switch options.output { switch options.output {