MCPcopy Create free account
hub / github.com/conforma/cli / writeStatusOutput

Function writeStatusOutput

cmd/validate/vsa.go:1580–1602  ·  view source on GitHub ↗

writeStatusOutput writes only the status format output based on overall result

(allData AllSectionsData, outputFormats []string, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

1578
1579// writeStatusOutput writes only the status format output based on overall result
1580func writeStatusOutput(allData AllSectionsData, outputFormats []string, cmd *cobra.Command) error {
1581 resultStr := statusFailure
1582 if allData.OverallPassed {
1583 resultStr = statusSuccess
1584 }
1585
1586 statusReport := map[string]string{"result": resultStr}
1587 data, err := json.Marshal(statusReport)
1588 if err != nil {
1589 return fmt.Errorf("failed to marshal status report: %w", err)
1590 }
1591
1592 // Parse output spec to get file path if specified
1593 for _, outputSpec := range outputFormats {
1594 _, file := parseOutputSpec(outputSpec)
1595 fs := utils.FS(cmd.Context())
1596 if err := writeDataToOutput(data, outputFormatStatus, file, fs, cmd); err != nil {
1597 return err
1598 }
1599 }
1600
1601 return nil
1602}
1603
1604// isStatusOnlyFormat checks if the output formats contain only "status" format
1605func isStatusOnlyFormat(outputFormats []string) bool {

Callers 1

Calls 4

FSFunction · 0.92
parseOutputSpecFunction · 0.85
writeDataToOutputFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected