Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 5 additions & 6 deletions pkg/minikube/out/out.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func Step(st style.Enum, format string, a ...V) {
outStyled, _ := stylized(st, useColor, format, a...)
if JSON {
register.PrintStep(outStyled)
klog.Info(outStyled)
return
}
register.RecordStep(outStyled)
Expand Down Expand Up @@ -154,7 +155,6 @@ func Infof(format string, a ...V) {
outStyled, _ := stylized(style.Option, useColor, format, a...)
if JSON {
register.PrintInfo(outStyled)
return
}
String(outStyled)
}
Expand All @@ -163,8 +163,9 @@ func Infof(format string, a ...V) {
func String(format string, a ...interface{}) {
// Flush log buffer so that output order makes sense
klog.Flush()
defer klog.Flush()

if silent {
if silent || JSON {
klog.Infof(format, a...)
return
}
Expand Down Expand Up @@ -212,10 +213,6 @@ func spinnerString(format string, a ...interface{}) {

// Ln writes a basic formatted string with a newline to stdout
func Ln(format string, a ...interface{}) {
if JSON {
klog.Warningf("please use out.T to log steps in JSON")
return
}
String(format+"\n", a...)
}

Expand All @@ -229,6 +226,7 @@ func ErrT(st style.Enum, format string, a ...V) {
func Err(format string, a ...interface{}) {
if JSON {
register.PrintError(format)
klog.Warningf(format, a...)
return
}
register.RecordError(format)
Expand Down Expand Up @@ -271,6 +269,7 @@ func WarningT(format string, a ...V) {
}
st, _ := stylized(style.Warning, useColor, format, a...)
register.PrintWarning(st)
klog.Warning(st)
return
}
ErrT(style.Warning, format, a...)
Expand Down
30 changes: 19 additions & 11 deletions pkg/minikube/out/out_reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package out
import (
"strings"

"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/out/register"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/style"
Expand All @@ -35,19 +36,17 @@ func Error(k reason.Kind, format string, a ...V) {
"url": k.URL,
"issues": strings.Join(k.IssueURLs(), ","),
})
} else {
displayText(k, format, a...)
}
displayText(k, format, a...)
}

// WarnReason shows a warning reason
func WarnReason(k reason.Kind, format string, a ...V) {
if JSON {
msg := Fmt(format, a...)
register.PrintWarning(msg)
} else {
displayText(k, format, a...)
}
displayText(k, format, a...)
}

// indentMultiLine indents a message if it contains multiple lines
Expand All @@ -71,33 +70,42 @@ func displayText(k reason.Kind, format string, a ...V) {
st = style.KnownIssue
}

ErrT(st, format, a...)
determineOutput(st, format, a...)

if k.Advice != "" {

advice := indentMultiLine(Fmt(k.Advice, a...))
ErrT(style.Tip, Fmt("Suggestion: {{.advice}}", V{"advice": advice}))
determineOutput(style.Tip, Fmt("Suggestion: {{.advice}}", V{"advice": advice}))
}

if k.URL != "" {
ErrT(style.Documentation, "Documentation: {{.url}}", V{"url": k.URL})
determineOutput(style.Documentation, "Documentation: {{.url}}", V{"url": k.URL})
}

issueURLs := k.IssueURLs()
if len(issueURLs) == 1 {
ErrT(style.Issues, "Related issue: {{.url}}", V{"url": issueURLs[0]})
determineOutput(style.Issues, "Related issue: {{.url}}", V{"url": issueURLs[0]})
}

if len(issueURLs) > 1 {
ErrT(style.Issues, "Related issues:")
determineOutput(style.Issues, "Related issues:")
for _, i := range issueURLs {
ErrT(style.Issue, "{{.url}}", V{"url": i})
determineOutput(style.Issue, "{{.url}}", V{"url": i})
}
}

if k.NewIssueLink {
ErrT(style.Empty, "")
determineOutput(style.Empty, "")
displayGitHubIssueMessage()
}
Ln("")
}

func determineOutput(st style.Enum, format string, a ...V) {
if !JSON {
ErrT(st, format, a...)
return
}
errStyled, _ := stylized(st, useColor, format, a...)
klog.Warning(errStyled)
}