Skip to content

Commit 99367a0

Browse files
committed
only print header during text mode
1 parent e8ed8e2 commit 99367a0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cmd/validate/vsa.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,10 @@ func buildFallbackReportData(fallbackResults []validate_utils.Result, vsaData *v
10751075

10761076
// displayFallbackImageSection - Displays fallback validate image output using WriteReport
10771077
func displayFallbackImageSection(allData AllSectionsData, vsaData *validateVSAData, cmd *cobra.Command) error {
1078-
fmt.Println("=== FALLBACK: VALIDATE IMAGE ===")
1078+
// Only print header for text output format (or when no format is specified, which defaults to text)
1079+
if shouldPrintFallbackHeader(vsaData.output) {
1080+
fmt.Println("=== FALLBACK: VALIDATE IMAGE ===")
1081+
}
10791082

10801083
reportData, err := buildFallbackReportData(allData.FallbackResults, vsaData)
10811084
if err != nil {
@@ -1094,6 +1097,19 @@ func displayFallbackImageSection(allData AllSectionsData, vsaData *validateVSADa
10941097
return err
10951098
}
10961099

1100+
// shouldPrintFallbackHeader determines if the fallback header should be printed
1101+
// The header should only be printed when using text format or when no format is specified
1102+
// (which defaults to text in WriteReport)
1103+
func shouldPrintFallbackHeader(outputFormats []string) bool {
1104+
// If no output formats specified, WriteReport defaults to text
1105+
if len(outputFormats) == 0 {
1106+
return true
1107+
}
1108+
1109+
// Check if "text" format is in the output formats
1110+
return validate_utils.ContainsOutputFormat(outputFormats, "text")
1111+
}
1112+
10971113
// toVSASectionsReport converts ComponentResultsDisplay to VSASectionsReport
10981114
func (d ComponentResultsDisplay) toVSASectionsReport() VSASectionsReport {
10991115
report := VSASectionsReport{

0 commit comments

Comments
 (0)