toFormat converts ComponentResultsDisplay to the specified format For text format, uses ComponentResultsDisplay to leverage existing String() methods
(format string)
| 1226 | // toFormat converts ComponentResultsDisplay to the specified format |
| 1227 | // For text format, uses ComponentResultsDisplay to leverage existing String() methods |
| 1228 | func (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 |
| 1244 | func (d ComponentResultsDisplay) toJSON() ([]byte, error) { |