MCPcopy Create free account
hub / github.com/cloudbase/garm / formatInstances

Function formatInstances

cmd/garm-cli/cmd/runner.go:416–451  ·  view source on GitHub ↗
(param []params.Instance, detailed bool, includeParent bool)

Source from the content-addressed store, hash-verified

414}
415
416func formatInstances(param []params.Instance, detailed bool, includeParent bool) {
417 if outputFormat == common.OutputFormatJSON {
418 printAsJSON(param)
419 return
420 }
421 t := table.NewWriter()
422 header := table.Row{"Nr", "Name", "Status", "Runner Status"}
423 if includeParent {
424 header = append(header, "Pool / Scale Set")
425 }
426 if detailed {
427 header = append(header, "Created At", "Updated At", "Job Name", "Started At", "Run ID", "Repository")
428 }
429 t.AppendHeader(header)
430
431 for idx, inst := range param {
432 row := table.Row{idx + 1, inst.Name, inst.Status, inst.RunnerStatus}
433 if includeParent {
434 poolOrScaleSet := fmt.Sprintf("Pool: %v", inst.PoolID)
435 if inst.ScaleSetID > 0 {
436 poolOrScaleSet = fmt.Sprintf("Scale Set: %d", inst.ScaleSetID)
437 }
438 row = append(row, poolOrScaleSet)
439 }
440 if detailed {
441 row = append(row, inst.CreatedAt, inst.UpdatedAt)
442 if inst.Job != nil {
443 repo := fmt.Sprintf("%s/%s", inst.Job.RepositoryOwner, inst.Job.RepositoryName)
444 row = append(row, inst.Job.Name, inst.Job.StartedAt, inst.Job.RunID, repo)
445 }
446 }
447 t.AppendRow(row)
448 t.AppendSeparator()
449 }
450 fmt.Println(t.Render())
451}
452
453func formatSingleInstance(instance params.Instance) {
454 if outputFormat == common.OutputFormatJSON {

Callers 3

scalesets.goFile · 0.85
pool.goFile · 0.85
runner.goFile · 0.85

Calls 1

printAsJSONFunction · 0.85

Tested by

no test coverage detected