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
pull/21270/head
Medya Ghazizadeh 2025-08-08 17:59:03 -07:00 committed by GitHub
parent c4a2e11710
commit 6b0b64e1db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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 {