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 casepull/21270/head
parent
c4a2e11710
commit
6b0b64e1db
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue