Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! status: show new status page
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicatoscani committed Aug 3, 2023
1 parent 6e52bfc commit 0a28ec0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"fmt"
"os"

"github.com/spf13/cobra"
Expand All @@ -10,7 +11,7 @@ import (
"github.com/exoscale/cli/table"
)

// https://www.statuspal.io/api-docs#tag/Status/operation/getStatusPageStatus
// REF: https://www.statuspal.io/api-docs#tag/Status/operation/getStatusPageStatus
const (
statusPageSubdomain = "exoscalestatus"
)
Expand All @@ -19,9 +20,13 @@ func init() {

// Global flags have no effect here, hide them
statusCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
cmd.Flags().MarkHidden("quiet")
cmd.Flags().MarkHidden("output-format")
cmd.Flags().MarkHidden("output-template")
for _, flags := range []string{"quiet", "output-format", "output-template"} {

err := cmd.Flags().MarkHidden(flags)
if err != nil {
fmt.Print(err)
}
}
cmd.Parent().HelpFunc()(cmd, args)
})
RootCmd.AddCommand(statusCmd)
Expand Down Expand Up @@ -57,12 +62,13 @@ func statusShow() error {
t.Append([]string{"Services", buf.String()})
buf.Reset()

// Get the impacted services by zone
// Get the impacted services by zone (incidents and maintenances)
incidents, maintenances, err := status.GetIncidents()
if err != nil {
return err
}

// Show incidents currently taking place
if len(incidents) > 0 {
it := table.NewEmbeddedTable(buf)
it.Table.AppendBulk(incidents)
Expand All @@ -73,6 +79,7 @@ func statusShow() error {
t.Append([]string{"Incidents", buf.String()})
buf.Reset()

// Show maintenances currently taking place
if len(maintenances) > 0 {
mt := table.NewEmbeddedTable(buf)
mt.Table.AppendBulk(maintenances)
Expand Down
6 changes: 3 additions & 3 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type StatusPalStatus struct {

// Get the status of global services (status of global or zones, no details of impacted services)
func (s StatusPalStatus) GetStatusByZone() ([][]string, error) {
var global [][]string
global := make([][]string, len(s.Services))
for _, svc := range s.Services {
state := svc.getIncidentType()
global = append(global, []string{*svc.Name, state})
Expand All @@ -40,8 +40,8 @@ func (s StatusPalStatus) GetStatusByZone() ([][]string, error) {
func (s StatusPalStatus) GetIncidents() ([][]string, [][]string, error) {
var incidents IncidentsDetails
var maintenances IncidentsDetails
var services Services
services = s.Services

services := s.Services
// In Incidents, we have maintenances and incidents currently taking place
// We need to show them in different tables
for _, event := range s.Incidents {
Expand Down

0 comments on commit 0a28ec0

Please sign in to comment.