Skip to content

Commit b9615bf

Browse files
authored
Merge pull request #9390 from prezha/json-output-cleanup
reword error message when cluster state exit code is not found
2 parents 6e337ab + 0c3843b commit b9615bf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/minikube/cmd/status.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"k8s.io/minikube/pkg/minikube/machine"
4545
"k8s.io/minikube/pkg/minikube/mustload"
4646
"k8s.io/minikube/pkg/minikube/node"
47+
"k8s.io/minikube/pkg/minikube/out"
4748
"k8s.io/minikube/pkg/minikube/out/register"
4849
"k8s.io/minikube/pkg/minikube/reason"
4950
"k8s.io/minikube/pkg/version"
@@ -196,10 +197,13 @@ var statusCmd = &cobra.Command{
196197
Exit status contains the status of minikube's VM, cluster and Kubernetes encoded on it's bits in this order from right to left.
197198
Eg: 7 meaning: 1 (for minikube NOK) + 2 (for cluster NOK) + 4 (for Kubernetes NOK)`,
198199
Run: func(cmd *cobra.Command, args []string) {
200+
output = strings.ToLower(output)
199201
if output != "text" && statusFormat != defaultStatusFormat {
200202
exit.Message(reason.Usage, "Cannot use both --output and --format options")
201203
}
202204

205+
out.SetJSON(output == "json")
206+
203207
cname := ClusterFlagValue()
204208
api, cc := mustload.Partial(cname)
205209

@@ -233,7 +237,7 @@ var statusCmd = &cobra.Command{
233237
}
234238
}
235239

236-
switch strings.ToLower(output) {
240+
switch output {
237241
case "text":
238242
for _, st := range statuses {
239243
if err := statusText(st, os.Stdout); err != nil {
@@ -544,7 +548,7 @@ func clusterState(sts []*Status) ClusterState {
544548
}
545549
exitCode, err := strconv.Atoi(data["exitcode"])
546550
if err != nil {
547-
klog.Errorf("unable to convert exit code to int: %v", err)
551+
klog.Errorf("exit code not found: %v", err)
548552
continue
549553
}
550554
if val, ok := exitCodeToHTTPCode[exitCode]; ok {

0 commit comments

Comments
 (0)