MCPcopy Index your code
hub / github.com/FairwindsOps/pluto / PrintVersionList

Method PrintVersionList

pkg/api/versions.go:271–303  ·  view source on GitHub ↗

PrintVersionList prints out the list of versions in a specific format

(outputFormat string)

Source from the content-addressed store, hash-verified

269// PrintVersionList prints out the list of versions
270// in a specific format
271func (instance *Instance) PrintVersionList(outputFormat string) error {
272 switch outputFormat {
273 case "normal", "wide":
274 err := instance.printVersionsTabular()
275 if err != nil {
276 return err
277 }
278 case "json":
279 versionFile := VersionFile{
280 DeprecatedVersions: instance.DeprecatedVersions,
281 TargetVersions: instance.TargetVersions,
282 }
283 data, err := json.Marshal(versionFile)
284 if err != nil {
285 return err
286 }
287 fmt.Println(string(data))
288 case "yaml":
289 versionFile := VersionFile{
290 DeprecatedVersions: instance.DeprecatedVersions,
291 TargetVersions: instance.TargetVersions,
292 }
293 data, err := yaml.Marshal(versionFile)
294 if err != nil {
295 return err
296 }
297 fmt.Println(string(data))
298 default:
299 fmt.Println("The output format must be one of (normal|wide|json|yaml)")
300 return fmt.Errorf("The output format must be one of (normal|wide|json|yaml)")
301 }
302 return nil
303}
304
305func (instance *Instance) printVersionsTabular() error {
306 w := new(tabwriter.Writer)

Calls 1

printVersionsTabularMethod · 0.95