diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index a01a4658f0c1..b881c6d84d4f 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -541,13 +541,15 @@ func handleSingleDeletionError(err error) { if ok { switch deletionError.Errtype { case Fatal: - out.FatalT(deletionError.Error()) + out.ErrT(style.Fatal, "Failed to delete profile(s): {{.error}}", out.V{"error": deletionError.Error()}) + os.Exit(reason.ExGuestError) case MissingProfile: out.ErrT(style.Sad, deletionError.Error()) case MissingCluster: out.ErrT(style.Meh, deletionError.Error()) default: - out.FatalT(deletionError.Error()) + out.ErrT(style.Fatal, "Unable to delete profile(s): {{.error}}", out.V{"error": deletionError.Error()}) + os.Exit(reason.ExGuestError) } } else { exit.Error(reason.GuestDeletion, "Could not process error from failed deletion", err) diff --git a/cmd/minikube/cmd/node_stop.go b/cmd/minikube/cmd/node_stop.go index 65c92f71f8af..b8f59f8c18cf 100644 --- a/cmd/minikube/cmd/node_stop.go +++ b/cmd/minikube/cmd/node_stop.go @@ -17,6 +17,8 @@ limitations under the License. package cmd import ( + "os" + "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" @@ -49,7 +51,8 @@ var nodeStopCmd = &cobra.Command{ err = machine.StopHost(api, machineName) if err != nil { - out.FatalT("Failed to stop node {{.name}}", out.V{"name": name}) + out.ErrT(style.Fatal, "Failed to stop node {{.name}}: {{.error}}", out.V{"name": name, "error": err}) + os.Exit(reason.ExHostError) } out.Step(style.Stopped, "Successfully stopped node {{.name}}", out.V{"name": machineName}) }, diff --git a/cmd/minikube/cmd/service.go b/cmd/minikube/cmd/service.go index 9914302ff907..28df4bbb8cca 100644 --- a/cmd/minikube/cmd/service.go +++ b/cmd/minikube/cmd/service.go @@ -98,8 +98,7 @@ var serviceCmd = &cobra.Command{ var services service.URLs services, err := service.GetServiceURLs(co.API, co.Config.Name, namespace, serviceURLTemplate) if err != nil { - out.FatalT("Failed to get service URL: {{.error}}", out.V{"error": err}) - out.ErrT(style.Notice, "Check that minikube is running and that you have specified the correct namespace (-n flag) if required.") + out.ErrT(style.Fatal, "Failed to get service URL - check that minikube is running and that you have specified the correct namespace (-n flag) if required: {{.error}}", out.V{"error": err}) os.Exit(reason.ExSvcUnavailable) } diff --git a/cmd/minikube/cmd/service_list.go b/cmd/minikube/cmd/service_list.go index 99fd13b7d93e..338c993d0180 100644 --- a/cmd/minikube/cmd/service_list.go +++ b/cmd/minikube/cmd/service_list.go @@ -47,8 +47,7 @@ var serviceListCmd = &cobra.Command{ serviceURLs, err := service.GetServiceURLs(co.API, co.Config.Name, serviceListNamespace, serviceURLTemplate) if err != nil { - out.FatalT("Failed to get service URL: {{.error}}", out.V{"error": err}) - out.ErrT(style.Notice, "Check that minikube is running and that you have specified the correct namespace (-n flag) if required.") + out.ErrT(style.Fatal, "Failed to get service URL - check that minikube is running and that you have specified the correct namespace (-n flag) if required: {{.error}}", out.V{"error": err}) os.Exit(reason.ExSvcUnavailable) } serviceURLs = updatePortsAndURLs(serviceURLs, co) diff --git a/pkg/minikube/out/out.go b/pkg/minikube/out/out.go index 0043bc875031..4ce9ac62d1f8 100644 --- a/pkg/minikube/out/out.go +++ b/pkg/minikube/out/out.go @@ -255,11 +255,6 @@ func SuccessT(format string, a ...V) { Step(style.Success, format, a...) } -// FatalT is a shortcut for writing a templated fatal message to stderr -func FatalT(format string, a ...V) { - ErrT(style.Fatal, format, a...) -} - // WarningT is a shortcut for writing a templated warning message to stderr func WarningT(format string, a ...V) { if JSON { @@ -368,12 +363,12 @@ func LogEntries(msg string, err error, entries map[string][]string) { func displayError(msg string, err error) { klog.Warningf(fmt.Sprintf("%s: %v", msg, err)) if JSON { - FatalT("{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err}) + ErrT(style.Fatal, "{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err}) return } // use Warning because Error will display a duplicate message to stderr ErrT(style.Empty, "") - FatalT("{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err}) + ErrT(style.Fatal, "{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err}) ErrT(style.Empty, "") displayGitHubIssueMessage() }