-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]> Signed-off-by: Yoan Blanc <[email protected]>
- Loading branch information
1 parent
758496d
commit e886eca
Showing
35 changed files
with
2,366 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/exoscale/egoscale" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// runstatusCreateCmd represents the create command | ||
var runstatusCreateCmd = &cobra.Command{ | ||
Use: "create <page name>+", | ||
Short: "Create Runstat.us page", | ||
Aliases: gCreateAlias, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 1 { | ||
return cmd.Usage() | ||
} | ||
|
||
dark, err := cmd.Flags().GetBool("dark") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, arg := range args { | ||
result, err := csRunstatus.CreateRunstatusPage(gContext, egoscale.RunstatusPage{ | ||
Name: arg, | ||
Subdomain: arg, | ||
DarkTheme: dark, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("Runstat.us page %q created:\n - %s\n", result.Subdomain, result.PublicURL) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
runstatusCmd.AddCommand(runstatusCreateCmd) | ||
runstatusCreateCmd.Flags().BoolP("dark", "d", false, "Enable status page dark mode") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/exoscale/egoscale" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// deleteCmd represents the delete command | ||
var runstatusDeleteCmd = &cobra.Command{ | ||
Use: "delete <page name>+", | ||
Short: "Delete runstat.us page(s)", | ||
Aliases: gDeleteAlias, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 1 { | ||
return cmd.Usage() | ||
} | ||
for _, arg := range args { | ||
if !askQuestion(fmt.Sprintf("sure you want to delete %q runstat.us page", arg)) { | ||
continue | ||
} | ||
|
||
runstatusPage, err := csRunstatus.GetRunstatusPage(gContext, egoscale.RunstatusPage{Subdomain: arg}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := csRunstatus.DeleteRunstatusPage(gContext, *runstatusPage); err != nil { | ||
return err | ||
} | ||
fmt.Printf("Page %q successfully deleted\n", arg) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
runstatusCmd.AddCommand(runstatusDeleteCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/exoscale/egoscale" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// runstatusIncidentCmd represents the incident command | ||
var runstatusIncidentCmd = &cobra.Command{ | ||
Use: "incident", | ||
Short: "Incident management", | ||
} | ||
|
||
func getIncidentByNameOrID(page egoscale.RunstatusPage, name string) (*egoscale.RunstatusIncident, error) { | ||
|
||
incidentID := -1 | ||
|
||
id, err := strconv.Atoi(name) | ||
if err == nil { | ||
incidentID = id | ||
} | ||
|
||
if incidentID > 0 { | ||
return csRunstatus.GetRunstatusIncident(gContext, egoscale.RunstatusIncident{PageURL: page.URL, ID: incidentID}) | ||
} | ||
|
||
return csRunstatus.GetRunstatusIncident(gContext, egoscale.RunstatusIncident{PageURL: page.URL, Title: name}) | ||
} | ||
|
||
func init() { | ||
runstatusCmd.AddCommand(runstatusIncidentCmd) | ||
} |
Oops, something went wrong.