Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add T versions of the console convenience functions #4796

Merged
merged 6 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func runDelete(cmd *cobra.Command, args []string) {
if err = cluster.DeleteHost(api); err != nil {
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
console.OutStyle(console.Meh, "%q cluster does not exist", profile)
console.OutT(console.Meh, `"{{.name}}" cluster does not exist`, console.Arg{"name": profile})
default:
exit.WithError("Failed to delete cluster", err)
}
Expand Down
20 changes: 20 additions & 0 deletions pkg/minikube/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ func Failure(format string, a ...interface{}) {
ErrStyle(FailureType, format, a...)
}

// SuccessT is a shortcut for writing a templated success message to stdout
func SuccessT(format string, a Arg) {
OutT(SuccessType, format, a)
}

// FatalT is a shortcut for writing a templated fatal message to stderr
func FatalT(format string, a Arg) {
ErrStyle(FatalType, format, a)
}

// WarningT is a shortcut for writing a templated warning message to stderr
func WarningT(format string, a Arg) {
ErrStyle(WarningType, format, a)
}

// FailureT is a shortcut for writing a templated failure message to stderr
func FailureT(format string, a Arg) {
ErrStyle(FailureType, format, a)
}

// SetOutFile configures which writer standard output goes to.
func SetOutFile(w fdWriter) {
glog.Infof("Setting OutFile to fd %d ...", w.Fd())
Expand Down
6 changes: 3 additions & 3 deletions pkg/minikube/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func displayError(msg string, err error) {
// use Warning because Error will display a duplicate message to stderr
glog.Warningf(fmt.Sprintf("%s: %v", msg, err))
console.Err("\n")
console.Fatal("%s: %v", msg, err)
console.FatalT("{{.msg}}: {{.err}}", console.Arg{"msg": msg, "err": err})
console.Err("\n")
console.ErrStyle(console.Sad, "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:")
console.ErrStyle(console.URL, "https://github.com/kubernetes/minikube/issues/new/choose")
console.ErrT(console.Sad, "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:", console.Arg{})
console.ErrT(console.URL, "https://github.com/kubernetes/minikube/issues/new/choose", console.Arg{})
}