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

Method toFormat

cmd/validate/vsa.go:1228–1241  ·  view source on GitHub ↗

toFormat converts ComponentResultsDisplay to the specified format For text format, uses ComponentResultsDisplay to leverage existing String() methods

(format string)

Source from the content-addressed store, hash-verified

1226// toFormat converts ComponentResultsDisplay to the specified format
1227// For text format, uses ComponentResultsDisplay to leverage existing String() methods
1228func (d ComponentResultsDisplay) toFormat(format string) ([]byte, error) {
1229 switch format {
1230 case outputFormatJSON:
1231 return d.toJSON()
1232 case outputFormatYAML:
1233 return d.toYAML()
1234 case outputFormatText:
1235 return d.toText(), nil
1236 case outputFormatStatus:
1237 return d.toStatus()
1238 default:
1239 return nil, fmt.Errorf("unsupported format: %s (supported: %s, %s, %s, %s)", format, outputFormatJSON, outputFormatYAML, outputFormatText, outputFormatStatus)
1240 }
1241}
1242
1243// toJSON converts ComponentResultsDisplay to JSON format
1244func (d ComponentResultsDisplay) toJSON() ([]byte, error) {

Callers 1

WriteAllMethod · 0.95

Calls 5

toJSONMethod · 0.95
toYAMLMethod · 0.95
toTextMethod · 0.95
toStatusMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected