mirror of https://github.com/kubernetes/kops.git
`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:
parent
f14b5a564a
commit
5a89dd113c
|
@ -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{}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue