added message to box
parent
d17e47ca7f
commit
cd93ee9eb4
|
@ -199,7 +199,7 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri
|
||||||
return errors.Wrap(err, "registry port")
|
return errors.Wrap(err, "registry port")
|
||||||
}
|
}
|
||||||
if enable {
|
if enable {
|
||||||
out.Boxed(style.Tip, `Registry addon with {{.driver}} driver uses port {{.port}} please use that instead of default port 5000`, out.V{"driver": cc.Driver, "port": port})
|
out.Boxed(`Registry addon with {{.driver}} driver uses port {{.port}} please use that instead of default port 5000`, out.V{"driver": cc.Driver, "port": port})
|
||||||
}
|
}
|
||||||
out.Styled(style.Documentation, `For more information see: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}`, out.V{"driver": cc.Driver})
|
out.Styled(style.Documentation, `For more information see: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}`, out.V{"driver": cc.Driver})
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,17 +114,14 @@ func Styled(st style.Enum, format string, a ...V) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boxed writes a stylized and templated message in a box to stdout
|
// Boxed writes a stylized and templated message in a box to stdout
|
||||||
func Boxed(st style.Enum, format string, a ...V) {
|
func Boxed(format string, a ...V) {
|
||||||
str := Sprintf(style.None, format, a...)
|
str := Sprintf(style.None, format, a...)
|
||||||
str = strings.TrimSpace(str)
|
str = strings.TrimSpace(str)
|
||||||
box := box.New(box.Config{Type: "Round"})
|
box := box.New(box.Config{Py: 1, Px: 4, Type: "Round"})
|
||||||
if useColor {
|
if useColor {
|
||||||
box.Config.Color = "Red"
|
box.Config.Color = "Red"
|
||||||
}
|
}
|
||||||
txt := strings.Split(box.String("", str), "\n")
|
box.Println("", str)
|
||||||
Styled(style.Indent, txt[0])
|
|
||||||
Styled(st, txt[1])
|
|
||||||
Styled(style.Indent, txt[2])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sprintf is used for returning the string (doesn't write anything)
|
// Sprintf is used for returning the string (doesn't write anything)
|
||||||
|
@ -360,14 +357,18 @@ func displayError(msg string, err error) {
|
||||||
ErrT(style.Empty, "")
|
ErrT(style.Empty, "")
|
||||||
FatalT("{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err})
|
FatalT("{{.msg}}: {{.err}}", V{"msg": translate.T(msg), "err": err})
|
||||||
ErrT(style.Empty, "")
|
ErrT(style.Empty, "")
|
||||||
ErrT(style.Sad, "minikube is exiting due to an error. If the above message is not useful, open an issue:")
|
displayGitHubIssueMessage()
|
||||||
ErrT(style.URL, "https://github.com/kubernetes/minikube/issues/new/choose")
|
|
||||||
if err := displayLogLocationMessage(); err != nil {
|
|
||||||
klog.Warningf("failed to display log location message: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLatestLogFilePath() (string, error) {
|
func latestLogFilePath() (string, error) {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
return "", fmt.Errorf("unable to detect command")
|
||||||
|
}
|
||||||
|
cmd := os.Args[1]
|
||||||
|
if cmd == "start" {
|
||||||
|
return localpath.LastStartLog(), nil
|
||||||
|
}
|
||||||
|
|
||||||
tmpdir := os.TempDir()
|
tmpdir := os.TempDir()
|
||||||
files, err := ioutil.ReadDir(tmpdir)
|
files, err := ioutil.ReadDir(tmpdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -390,22 +391,20 @@ func getLatestLogFilePath() (string, error) {
|
||||||
return fullPath, nil
|
return fullPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func displayLogLocationMessage() error {
|
func displayGitHubIssueMessage() {
|
||||||
if len(os.Args) < 2 {
|
logPath, err := latestLogFilePath()
|
||||||
return fmt.Errorf("unable to detect command")
|
if err != nil {
|
||||||
|
klog.Warningf("failed to diplay GitHub issue message: %v", err)
|
||||||
}
|
}
|
||||||
logPath := localpath.LastStartLog()
|
|
||||||
cmd := os.Args[1]
|
|
||||||
if cmd != "start" {
|
|
||||||
var err error
|
|
||||||
logPath, err = getLatestLogFilePath()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ErrT(style.Tip, "If you are able to drag and drop the following log-file into the issue, we'll be able to make faster progress: {{.logPath}}", V{"logPath": logPath})
|
|
||||||
|
|
||||||
return nil
|
msg := `If the above advice does not help, please let us know:
|
||||||
|
https://github.com/kubernetes/minikube/issues/new/choose
|
||||||
|
|
||||||
|
Please attach the following file to the GitHub issue:
|
||||||
|
- `
|
||||||
|
msg += logPath
|
||||||
|
|
||||||
|
Boxed(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// applyTmpl applies formatting
|
// applyTmpl applies formatting
|
||||||
|
|
|
@ -36,7 +36,6 @@ package out
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
|
||||||
"k8s.io/minikube/pkg/minikube/out/register"
|
"k8s.io/minikube/pkg/minikube/out/register"
|
||||||
"k8s.io/minikube/pkg/minikube/reason"
|
"k8s.io/minikube/pkg/minikube/reason"
|
||||||
"k8s.io/minikube/pkg/minikube/style"
|
"k8s.io/minikube/pkg/minikube/style"
|
||||||
|
@ -114,11 +113,7 @@ func displayText(k reason.Kind, format string, a ...V) {
|
||||||
|
|
||||||
if k.NewIssueLink {
|
if k.NewIssueLink {
|
||||||
ErrT(style.Empty, "")
|
ErrT(style.Empty, "")
|
||||||
ErrT(style.Sad, "If the above advice does not help, please let us know: ")
|
displayGitHubIssueMessage()
|
||||||
ErrT(style.URL, "https://github.com/kubernetes/minikube/issues/new/choose")
|
|
||||||
if err := displayLogLocationMessage(); err != nil {
|
|
||||||
klog.Warningf("failed to display log location message: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ln("")
|
Ln("")
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"k8s.io/minikube/pkg/minikube/localpath"
|
||||||
"k8s.io/minikube/pkg/minikube/style"
|
"k8s.io/minikube/pkg/minikube/style"
|
||||||
"k8s.io/minikube/pkg/minikube/tests"
|
"k8s.io/minikube/pkg/minikube/tests"
|
||||||
"k8s.io/minikube/pkg/minikube/translate"
|
"k8s.io/minikube/pkg/minikube/translate"
|
||||||
|
@ -128,22 +128,7 @@ func createLogFile() (string, error) {
|
||||||
return f.Name(), nil
|
return f.Name(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetLatestLogPath(t *testing.T) {
|
func TestLatestLogPath(t *testing.T) {
|
||||||
want, err := createLogFile()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(want)
|
|
||||||
got, err := getLatestLogFilePath()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to get latest log file name: %v", err)
|
|
||||||
}
|
|
||||||
if got != want {
|
|
||||||
t.Errorf("getLatestLogPath() = %q; want %q", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDisplayLogLocationMessage(t *testing.T) {
|
|
||||||
filename, err := createLogFile()
|
filename, err := createLogFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -156,7 +141,7 @@ func TestDisplayLogLocationMessage(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
[]string{"minikube", "start"},
|
[]string{"minikube", "start"},
|
||||||
"lastStart.txt",
|
localpath.LastStartLog(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"minikube", "status"},
|
[]string{"minikube", "status"},
|
||||||
|
@ -168,14 +153,12 @@ func TestDisplayLogLocationMessage(t *testing.T) {
|
||||||
oldArgs := os.Args
|
oldArgs := os.Args
|
||||||
defer func() { os.Args = oldArgs }()
|
defer func() { os.Args = oldArgs }()
|
||||||
os.Args = tt.args
|
os.Args = tt.args
|
||||||
f := tests.NewFakeFile()
|
got, err := latestLogFilePath()
|
||||||
SetErrFile(f)
|
if err != nil {
|
||||||
if err := displayLogLocationMessage(); err != nil {
|
t.Fatalf("failed latestLogFilePath(): %v", err)
|
||||||
t.Fatalf("failed to displayLogLocationMessage: %v", err)
|
|
||||||
}
|
}
|
||||||
got := f.String()
|
if got != tt.want {
|
||||||
if !strings.Contains(got, tt.want) {
|
t.Errorf("oa.Args = %s; latestLogFilePath() = %q; wanted to contain %q", tt.args, got, tt.want)
|
||||||
t.Errorf("displayLogLocationMessage() = %q; wanted to contain %q", got, tt.want)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue