-
Notifications
You must be signed in to change notification settings - Fork 20
/
runstatus.go
46 lines (37 loc) · 999 Bytes
/
runstatus.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
package cmd
import (
"fmt"
"time"
"github.com/exoscale/egoscale"
"github.com/spf13/cobra"
)
// runstatusCmd represents the runstatus command
var runstatusCmd = &cobra.Command{
Use: "runstatus",
Short: "Manage your Runstat.us pages",
Long: `Focus on building your service,
knowing that when something does go wrong you can keep everyone informed using Runstatus.`,
}
func init() {
RootCmd.AddCommand(runstatusCmd)
}
func getRunstatusPages(names []string) ([]egoscale.RunstatusPage, error) {
if len(names) == 0 {
return csRunstatus.ListRunstatusPages(gContext)
}
pages := []egoscale.RunstatusPage{}
for _, name := range names {
page, err := csRunstatus.GetRunstatusPage(gContext, egoscale.RunstatusPage{Subdomain: name})
if err != nil {
return nil, err
}
pages = append(pages, *page)
}
return pages, nil
}
func formatSchedule(start, end *time.Time) string {
if start == nil || end == nil {
return ""
}
return fmt.Sprintf("%s - %s", start, end.Sub(*start))
}