-
Notifications
You must be signed in to change notification settings - Fork 19
/
runstatus_maintenance_list.go
50 lines (42 loc) · 1.06 KB
/
runstatus_maintenance_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"os"
"strconv"
"github.com/exoscale/cli/table"
"github.com/spf13/cobra"
)
// listCmd represents the list command
var runstatusMaintenanceListCmd = &cobra.Command{
Use: "list [page name]+",
Short: "List maintenance from page(s)",
Aliases: gListAlias,
RunE: func(cmd *cobra.Command, args []string) error {
pages, err := runstatusAllPages(args)
if err != nil {
return err
}
table := table.NewTable(os.Stdout)
table.SetHeader([]string{"Page Name", "Title", "Status", "When", "ID"})
for _, page := range pages {
maintenances, err := csRunstatus.ListRunstatusMaintenances(gContext, page)
if err != nil {
return err
}
for _, maintenance := range maintenances {
table.Append([]string{
page.Subdomain,
maintenance.Title,
maintenance.Status,
formatSchedule(maintenance.StartDate, maintenance.EndDate),
strconv.Itoa(maintenance.ID),
})
page.Subdomain = ""
}
}
table.Render()
return nil
},
}
func init() {
runstatusMaintenanceCmd.AddCommand(runstatusMaintenanceListCmd)
}