@@ -25,6 +25,7 @@ import (
25
25
"github.com/golang/glog"
26
26
"k8s.io/minikube/pkg/minikube/console"
27
27
"k8s.io/minikube/pkg/minikube/problem"
28
+ "k8s.io/minikube/pkg/minikube/translate"
28
29
)
29
30
30
31
// Exit codes based on sysexits(3)
@@ -50,6 +51,12 @@ func Usage(format string, a ...interface{}) {
50
51
os .Exit (BadUsage )
51
52
}
52
53
54
+ // UsageT outputs a templated usage error and exits with error code 64
55
+ func UsageT (format string , a ... console.Arg ) {
56
+ console .ErrT (console .Usage , format , a ... )
57
+ os .Exit (BadUsage )
58
+ }
59
+
53
60
// WithCode outputs a fatal error message and exits with a supplied error code.
54
61
func WithCode (code int , format string , a ... interface {}) {
55
62
// use Warning because Error will display a duplicate message to stderr
@@ -58,6 +65,12 @@ func WithCode(code int, format string, a ...interface{}) {
58
65
os .Exit (code )
59
66
}
60
67
68
+ // WithCodeT outputs a templated fatal error message and exits with the supplied error code.
69
+ func WithCodeT (code int , format string , a ... console.Arg ) {
70
+ console .FatalT (format , a ... )
71
+ os .Exit (code )
72
+ }
73
+
61
74
// WithError outputs an error and exits.
62
75
func WithError (msg string , err error ) {
63
76
p := problem .FromError (err , runtime .GOOS )
@@ -71,11 +84,11 @@ func WithError(msg string, err error) {
71
84
// WithProblem outputs info related to a known problem and exits.
72
85
func WithProblem (msg string , p * problem.Problem ) {
73
86
console .Err ("\n " )
74
- console .Fatal (msg )
87
+ console .FatalT (msg )
75
88
p .Display ()
76
89
console .Err ("\n " )
77
- console .ErrStyle (console .Sad , "If the above advice does not help, please let us know: " )
78
- console .ErrStyle (console .URL , "https://github.com/kubernetes/minikube/issues/new/choose" )
90
+ console .ErrT (console .Sad , "If the above advice does not help, please let us know: " )
91
+ console .ErrT (console .URL , "https://github.com/kubernetes/minikube/issues/new/choose" )
79
92
os .Exit (Config )
80
93
}
81
94
@@ -84,12 +97,12 @@ func WithLogEntries(msg string, err error, entries map[string][]string) {
84
97
displayError (msg , err )
85
98
86
99
for name , lines := range entries {
87
- console .OutStyle (console .FailureType , "Problems detected in %q :" , name )
100
+ console .OutT (console .FailureType , "Problems detected in {{.entry}} :" , console. Arg { "entry" : name } )
88
101
if len (lines ) > MaxLogEntries {
89
102
lines = lines [:MaxLogEntries ]
90
103
}
91
104
for _ , l := range lines {
92
- console .OutStyle (console .LogEntry , l )
105
+ console .OutT (console .LogEntry , l )
93
106
}
94
107
}
95
108
os .Exit (Software )
@@ -99,8 +112,8 @@ func displayError(msg string, err error) {
99
112
// use Warning because Error will display a duplicate message to stderr
100
113
glog .Warningf (fmt .Sprintf ("%s: %v" , msg , err ))
101
114
console .Err ("\n " )
102
- console .Fatal ( "%s: %v " , msg , err )
115
+ console .FatalT ( "{{.msg}}: {{.err}} " , console. Arg { " msg" : translate . T ( msg ), " err" : err } )
103
116
console .Err ("\n " )
104
- console .ErrStyle (console .Sad , "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:" )
105
- console .ErrStyle (console .URL , "https://github.com/kubernetes/minikube/issues/new/choose" )
117
+ console .ErrT (console .Sad , "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:" )
118
+ console .ErrT (console .URL , "https://github.com/kubernetes/minikube/issues/new/choose" )
106
119
}
0 commit comments