From 6b0b64e1db355d8a3a2e787aa17082bb23117d3b Mon Sep 17 00:00:00 2001 From: Medya Ghazizadeh Date: Fri, 8 Aug 2025 17:59:03 -0700 Subject: [PATCH] UI: do not show "create github issue" twice if kubeadm init fails (#21263) * do not show github issue in exist twice if kubeadm * Reset the flag for each test case --- pkg/minikube/out/out.go | 6 ++++++ pkg/minikube/out/out_test.go | 1 + 2 files changed, 7 insertions(+) diff --git a/pkg/minikube/out/out.go b/pkg/minikube/out/out.go index 9886315402..55300e564e 100644 --- a/pkg/minikube/out/out.go +++ b/pkg/minikube/out/out.go @@ -69,6 +69,8 @@ var ( spin = spinner.New(spinner.CharSets[style.SpinnerCharacter], 100*time.Millisecond, spinner.WithWriter(outFile)) // defaultBoxCfg is the default style config for cli box output defaultBoxCfg = box.Config{Py: 1, Px: 4, Type: "Round", Color: "Red"} + // alreadyShoweddGitHubIssueMessage is used to prevent showing the GitHub issue message multiple times + alreadyShoweddGitHubIssueMessage = false ) // MaxLogEntries controls the number of log entries to show for each source @@ -477,6 +479,9 @@ func command() (string, error) { } func displayGitHubIssueMessage() { + if alreadyShoweddGitHubIssueMessage { + return + } cmd, err := command() if err != nil { klog.Warningf("failed to get command: %v", err) @@ -496,6 +501,7 @@ func displayGitHubIssueMessage() { } BoxedErr(msg) + alreadyShoweddGitHubIssueMessage = true } // applyTmpl applies formatting diff --git a/pkg/minikube/out/out_test.go b/pkg/minikube/out/out_test.go index 151d8b3f81..de1f9ab953 100644 --- a/pkg/minikube/out/out_test.go +++ b/pkg/minikube/out/out_test.go @@ -230,6 +230,7 @@ func TestDisplayGitHubIssueMessage(t *testing.T) { pflag.Parse() f := tests.NewFakeFile() SetErrFile(f) + alreadyShoweddGitHubIssueMessage = false // Reset the flag for each test case displayGitHubIssueMessage() output := f.String() if strings.Contains(output, msg) && !tt.shouldContainMessage {