Skip to content

Commit 55608c1

Browse files
authored
feat(support-bundle): add text that explains where support bundle to share (#1595)
1 parent fa14616 commit 55608c1

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

cmd/troubleshoot/cli/interactive_results.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path"
8+
"strings"
89
"time"
910

1011
"github.com/mitchellh/go-wordwrap"
@@ -22,7 +23,7 @@ var (
2223
isShowingSaved = false
2324
)
2425

25-
func showInteractiveResults(supportBundleName string, analyzeResults []*analyzerunner.AnalyzeResult) error {
26+
func showInteractiveResults(supportBundleName string, analyzeResults []*analyzerunner.AnalyzeResult, archivePath string) error {
2627
if err := ui.Init(); err != nil {
2728
return errors.Wrap(err, "failed to create terminal ui")
2829
}
@@ -49,7 +50,7 @@ func showInteractiveResults(supportBundleName string, analyzeResults []*analyzer
4950
if err != nil {
5051
// show
5152
} else {
52-
showSaved(filename)
53+
showSaved(filename, archivePath)
5354
go func() {
5455
time.Sleep(time.Second * 5)
5556
isShowingSaved = false
@@ -214,18 +215,36 @@ func drawDetails(analysisResult *analyzerunner.AnalyzeResult) {
214215
ui.Render(message)
215216
}
216217

217-
func showSaved(filename string) {
218+
func showSaved(filename string, archivePath string) {
218219
termWidth, termHeight := ui.TerminalDimensions()
219220

221+
f := `A support bundle was generated and saved at %s.
222+
Please send this file to your software vendor for support.`
223+
additionalMessageText := fmt.Sprintf(f, archivePath)
224+
220225
savedMessage := widgets.NewParagraph()
221-
savedMessage.Text = fmt.Sprintf("Support Bundle analysis results saved to\n\n%s", filename)
226+
savedMessage.Text = fmt.Sprintf("Support Bundle analysis results saved to\n\n%s\n\n%s", filename, additionalMessageText)
222227
savedMessage.WrapText = true
223228
savedMessage.Border = true
224229

225-
left := termWidth/2 - 20
226-
right := termWidth/2 + 20
227-
top := termHeight/2 - 4
228-
bottom := termHeight/2 + 4
230+
// Split the text into lines and find the longest line
231+
lines := strings.Split(savedMessage.Text, "\n")
232+
maxLineLength := 0
233+
for _, line := range lines {
234+
if len(line) > maxLineLength {
235+
// maxLineLength is set to half of the line length to prevent the showing text with more space than needed
236+
maxLineLength = len(line)/2 + constants.MESSAGE_TEXT_PADDING
237+
}
238+
}
239+
240+
if maxLineLength > termWidth/2 {
241+
maxLineLength = termWidth / 2
242+
}
243+
244+
left := termWidth/2 - maxLineLength
245+
right := termWidth/2 + maxLineLength
246+
top := termHeight/2 - len(lines)
247+
bottom := termHeight/2 + len(lines)
229248

230249
savedMessage.SetRect(left, top, right, bottom)
231250
ui.Render(savedMessage)

cmd/troubleshoot/cli/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func runTroubleshoot(v *viper.Viper, args []string) error {
200200

201201
if len(response.AnalyzerResults) > 0 {
202202
if interactive {
203-
if err := showInteractiveResults(mainBundle.Name, response.AnalyzerResults); err != nil {
203+
if err := showInteractiveResults(mainBundle.Name, response.AnalyzerResults, response.ArchivePath); err != nil {
204204
interactive = false
205205
}
206206
} else {
@@ -227,7 +227,7 @@ the %s Admin Console to begin analysis.`
227227
return nil
228228
}
229229

230-
fmt.Printf("\n%s\n", response.ArchivePath)
230+
fmt.Printf("\nA support bundle was generated and saved at %s. Please send this file to your software vendor for support.\n", response.ArchivePath)
231231
return nil
232232
}
233233

0 commit comments

Comments
 (0)