| 451 | } |
| 452 | |
| 453 | func formatSingleInstance(instance params.Instance) { |
| 454 | if outputFormat == common.OutputFormatJSON { |
| 455 | printAsJSON(instance) |
| 456 | return |
| 457 | } |
| 458 | t := table.NewWriter() |
| 459 | |
| 460 | header := table.Row{"Field", "Value"} |
| 461 | |
| 462 | t.AppendHeader(header) |
| 463 | t.AppendRow(table.Row{"ID", instance.ID}, table.RowConfig{AutoMerge: false}) |
| 464 | t.AppendRow(table.Row{"Created At", instance.CreatedAt}) |
| 465 | t.AppendRow(table.Row{"Updated At", instance.UpdatedAt}) |
| 466 | t.AppendRow(table.Row{"Provider ID", instance.ProviderID}, table.RowConfig{AutoMerge: false}) |
| 467 | t.AppendRow(table.Row{"Name", instance.Name}, table.RowConfig{AutoMerge: false}) |
| 468 | t.AppendRow(table.Row{"OS Type", instance.OSType}, table.RowConfig{AutoMerge: false}) |
| 469 | t.AppendRow(table.Row{"OS Architecture", instance.OSArch}, table.RowConfig{AutoMerge: false}) |
| 470 | t.AppendRow(table.Row{"OS Name", instance.OSName}, table.RowConfig{AutoMerge: false}) |
| 471 | t.AppendRow(table.Row{"OS Version", instance.OSVersion}, table.RowConfig{AutoMerge: false}) |
| 472 | t.AppendRow(table.Row{"Status", instance.Status}, table.RowConfig{AutoMerge: false}) |
| 473 | t.AppendRow(table.Row{"Runner Status", instance.RunnerStatus}, table.RowConfig{AutoMerge: false}) |
| 474 | t.AppendRow(table.Row{"Capabilities", fmt.Sprintf("Shell: %v", instance.Capabilities.Shell)}, table.RowConfig{AutoMerge: true}) |
| 475 | |
| 476 | if instance.PoolID != "" { |
| 477 | t.AppendRow(table.Row{"Pool ID", instance.PoolID}, table.RowConfig{AutoMerge: false}) |
| 478 | } else if instance.ScaleSetID != 0 { |
| 479 | t.AppendRow(table.Row{"Scale Set ID", instance.ScaleSetID}, table.RowConfig{AutoMerge: false}) |
| 480 | } |
| 481 | |
| 482 | if len(instance.Addresses) > 0 { |
| 483 | for _, addr := range instance.Addresses { |
| 484 | t.AppendRow(table.Row{"Addresses", addr.Address}, table.RowConfig{AutoMerge: true}) |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if len(instance.ProviderFault) > 0 { |
| 489 | t.AppendRow(table.Row{"Provider Fault", string(instance.ProviderFault)}, table.RowConfig{AutoMerge: true}) |
| 490 | } |
| 491 | |
| 492 | if len(instance.StatusMessages) > 0 { |
| 493 | for _, msg := range instance.StatusMessages { |
| 494 | t.AppendRow(table.Row{"Status Updates", fmt.Sprintf("%s: %s", msg.CreatedAt.Format("2006-01-02T15:04:05"), msg.Message)}, table.RowConfig{AutoMerge: true}) |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | t.SetColumnConfigs([]table.ColumnConfig{ |
| 499 | {Number: 1, AutoMerge: true}, |
| 500 | {Number: 2, AutoMerge: false, WidthMax: 100}, |
| 501 | }) |
| 502 | fmt.Println(t.Render()) |
| 503 | } |