diff --git a/cmd/docs/docs.go b/cmd/docs/docs.go index e075680..87caf3b 100644 --- a/cmd/docs/docs.go +++ b/cmd/docs/docs.go @@ -1,15 +1,14 @@ - package main import ( "os" - docs "github.com/urfave/cli-docs/v3" cmd "github.com/openstatusHQ/cli/internal/cmd" + docs "github.com/urfave/cli-docs/v3" ) func main() { - app := cmd.NewApp() + app := cmd.NewApp() md, err := docs.ToMarkdown(app) if err != nil { panic(err) diff --git a/cmd/openstatus/main.go b/cmd/openstatus/main.go index 30e0a70..d8e6431 100644 --- a/cmd/openstatus/main.go +++ b/cmd/openstatus/main.go @@ -2,9 +2,9 @@ package main import ( "context" + cmd "github.com/openstatusHQ/cli/internal/cmd" "log" "os" - cmd "github.com/openstatusHQ/cli/internal/cmd" ) func main() { diff --git a/docs/openstatus-docs.md b/docs/openstatus-docs.md index bd4c0f6..c906813 100644 --- a/docs/openstatus-docs.md +++ b/docs/openstatus-docs.md @@ -10,7 +10,7 @@ openstatus # DESCRIPTION -OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. +OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. Please report any issues at https://github.com/openstatusHQ/cli/issues/new diff --git a/internal/cmd/app.go b/internal/cmd/app.go index 95a0600..7a0a5f1 100644 --- a/internal/cmd/app.go +++ b/internal/cmd/app.go @@ -13,7 +13,7 @@ func NewApp() *cli.Command { Suggest: true, Usage: "This is OpenStatus Command Line Interface, the OpenStatus.dev CLI", Description: "OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. \n\nPlease report any issues at https://github.com/openstatusHQ/cli/issues/new", - Version: "v0.0.6", + Version: "v0.0.7", Commands: []*cli.Command{ monitors.MonitorsCmd(), run.RunCmd(), diff --git a/internal/config/config.go b/internal/config/config.go index 9be0f46..e0aa28a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -21,7 +21,7 @@ func ReadConfig(path string) (*Config, error) { file := file.Provider(path) - err:= k.Load(file, yaml.Parser()) + err := k.Load(file, yaml.Parser()) if err != nil { return nil, err diff --git a/internal/config/monitor.go b/internal/config/monitor.go index 7db5eb9..6de740a 100644 --- a/internal/config/monitor.go +++ b/internal/config/monitor.go @@ -2,14 +2,14 @@ package config type Monitor struct { // Name of the monitor - Name string `json:"name" ,yaml:"name"` - Description string `json:"description,omitempty" ,yaml:"description,omitempty"` - Frequency Frequency `json:"frequency" ,yaml:"frequency"` + Name string `json:"name" ,yaml:"name"` + Description string `json:"description,omitempty" ,yaml:"description,omitempty"` + Frequency Frequency `json:"frequency" ,yaml:"frequency"` // Regions to run the request in Regions []Region `json:"regions" ,yaml:"regions"` // Whether the monitor is active - Active bool `json:"active"` - Kind CoordinateKind `json:"kind" ,yaml:"kind"` + Active bool `json:"active"` + Kind CoordinateKind `json:"kind" ,yaml:"kind"` // Number of retries to attempt Retry int64 `json:"retry,omitempty" ,yaml:"retry,omitempty"` // Whether the monitor is public @@ -17,7 +17,7 @@ type Monitor struct { // The HTTP Request we are sending Request Request `json:"request" ,yaml:"request"` // Time in milliseconds to wait before marking the request as degraded - DegradedAfter int64 `json:"degradedAfter,omitempty" ,yaml:"degradedAfter,omitempty"` + DegradedAfter int64 `json:"degradedAfter,omitempty" ,yaml:"degradedAfter,omitempty"` // Time in milliseconds to wait before marking the request as timed out Timeout int64 `json:"timeout,omitempty" ,yaml:"timeout,omitempty"` // Assertions to run on the response diff --git a/internal/config/openstatus.go b/internal/config/openstatus.go index 558e8a3..0a614d8 100644 --- a/internal/config/openstatus.go +++ b/internal/config/openstatus.go @@ -7,8 +7,6 @@ import ( type Monitors map[string]Monitor - - func ReadOpenStatus(path string) ([]Monitor, error) { f := file.Provider(path) @@ -39,7 +37,6 @@ func ReadOpenStatus(path string) ([]Monitor, error) { } } - var monitor []Monitor for _, value := range out { for _, assertion := range value.Assertions { diff --git a/internal/monitors/monitor_create.go b/internal/monitors/monitor_create.go index 68f1133..80839fa 100644 --- a/internal/monitors/monitor_create.go +++ b/internal/monitors/monitor_create.go @@ -48,10 +48,10 @@ func CreateMonitor(httpClient *http.Client, apiKey string, monitor config.Monito func GetMonitorCreateCmd() *cli.Command { monitorInfoCmd := cli.Command{ - Name: "create", - Usage: "Create monitors (beta)", + Name: "create", + Usage: "Create monitors (beta)", Description: "Create the monitors defined in the openstatus.yaml file", - UsageText: "openstatus monitors create [options]", + UsageText: "openstatus monitors create [options]", Action: func(ctx context.Context, cmd *cli.Command) error { diff --git a/internal/monitors/monitor_delete.go b/internal/monitors/monitor_delete.go index 6b637f4..1cfa4f8 100644 --- a/internal/monitors/monitor_delete.go +++ b/internal/monitors/monitor_delete.go @@ -11,8 +11,6 @@ import ( "github.com/urfave/cli/v3" ) - - func DeleteMonitor(httpClient *http.Client, apiKey string, monitorId string) error { if monitorId == "" { @@ -50,8 +48,8 @@ func DeleteMonitor(httpClient *http.Client, apiKey string, monitorId string) err func GetMonitorDeleteCmd() *cli.Command { monitorsCmd := cli.Command{ - Name: "delete", - Usage: "Delete a monitor", + Name: "delete", + Usage: "Delete a monitor", UsageText: "openstatus monitors delete [MonitorID] [options]", Flags: []cli.Flag{ diff --git a/internal/monitors/monitor_export.go b/internal/monitors/monitor_export.go index 9af8f0b..7138450 100644 --- a/internal/monitors/monitor_export.go +++ b/internal/monitors/monitor_export.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/yaml" ) -func ExportMonitor(httpClient *http.Client, apiKey string, path string ) error { +func ExportMonitor(httpClient *http.Client, apiKey string, path string) error { url := "https://api.openstatus.dev/v1/monitor" req, _ := http.NewRequest(http.MethodGet, url, nil) @@ -74,10 +74,10 @@ func ExportMonitor(httpClient *http.Client, apiKey string, path string ) error { } assertions = append(assertions, config.Assertion{ - Kind: kind, - Target: assertion.Target, + Kind: kind, + Target: assertion.Target, Compare: config.Compare(assertion.Compare), - Key: assertion.Key, + Key: assertion.Key, }) } @@ -109,10 +109,10 @@ func ExportMonitor(httpClient *http.Client, apiKey string, path string ) error { DegradedAfter: int64(monitor.DegradedAfter), Frequency: config.Frequency(monitor.Periodicity), // Regions: monitor.Regions, - Request: request, - Kind: config.CoordinateKind(monitor.JobType), - Retry: int64(monitor.Retry), - Regions: regions, + Request: request, + Kind: config.CoordinateKind(monitor.JobType), + Retry: int64(monitor.Retry), + Regions: regions, Assertions: assertions, } } @@ -136,8 +136,8 @@ func ExportMonitor(httpClient *http.Client, apiKey string, path string ) error { func GetMonitorExportCmd() *cli.Command { monitorInfoCmd := cli.Command{ - Name: "export", - Usage: "Export all your monitors", + Name: "export", + Usage: "Export all your monitors", UsageText: "openstatus monitor export [options]", Description: "Export all your monitors to YAML", Action: func(ctx context.Context, cmd *cli.Command) error { @@ -162,7 +162,7 @@ func GetMonitorExportCmd() *cli.Command { Usage: "The output file name ", DefaultText: "openstatus.yaml", Value: "openstatus.yaml", - Aliases: []string{"o"}, + Aliases: []string{"o"}, }, }, } diff --git a/internal/monitors/monitor_info.go b/internal/monitors/monitor_info.go index 2709b6c..af190e7 100644 --- a/internal/monitors/monitor_info.go +++ b/internal/monitors/monitor_info.go @@ -110,7 +110,7 @@ func GetMonitorInfoCmd() *cli.Command { monitorInfoCmd := cli.Command{ Name: "info", Usage: "Get a monitor information", - UsageText: "openstatus monitor info [MonitorID]", + UsageText: "openstatus monitor info [MonitorID]", Description: "Fetch the monitor information. The monitor information includes details such as name, description, endpoint, method, frequency, locations, active status, public status, timeout, degraded after, and body. The body is truncated to 40 characters.", Action: func(ctx context.Context, cmd *cli.Command) error { monitorId := cmd.Args().Get(0) diff --git a/internal/monitors/monitor_trigger.go b/internal/monitors/monitor_trigger.go index d6a72d0..4dc9a3c 100644 --- a/internal/monitors/monitor_trigger.go +++ b/internal/monitors/monitor_trigger.go @@ -53,9 +53,9 @@ func MonitorTrigger(httpClient *http.Client, apiKey string, monitorId string) er func GetMonitorsTriggerCmd() *cli.Command { monitorsCmd := cli.Command{ - Name: "trigger", - Usage: "Trigger a monitor execution", - UsageText: "openstatus monitors trigger [MonitorId] [options]", + Name: "trigger", + Usage: "Trigger a monitor execution", + UsageText: "openstatus monitors trigger [MonitorId] [options]", Description: "Trigger a monitor execution on demand. This command allows you to launch your tests on demand.", Flags: []cli.Flag{ &cli.StringFlag{ diff --git a/internal/monitors/monitors.go b/internal/monitors/monitors.go index 95b00cd..d607433 100644 --- a/internal/monitors/monitors.go +++ b/internal/monitors/monitors.go @@ -7,22 +7,22 @@ import ( ) type Monitor struct { - ID int `json:"id"` - Name string `json:"name"` - URL string `json:"url"` - Periodicity string `json:"periodicity"` - Description string `json:"description"` - Method string `json:"method"` - Regions []string `json:"regions"` - Active bool `json:"active"` - Public bool `json:"public"` - Timeout int `json:"timeout"` - DegradedAfter int `json:"degraded_after,omitempty"` - Body string `json:"body"` - Headers []Header `json:"headers,omitempty"` - Assertions []Assertion `json:"assertions,omitempty"` - Retry int `json:"retry"` - JobType string `json:"jobType"` + ID int `json:"id"` + Name string `json:"name"` + URL string `json:"url"` + Periodicity string `json:"periodicity"` + Description string `json:"description"` + Method string `json:"method"` + Regions []string `json:"regions"` + Active bool `json:"active"` + Public bool `json:"public"` + Timeout int `json:"timeout"` + DegradedAfter int `json:"degraded_after,omitempty"` + Body string `json:"body"` + Headers []Header `json:"headers,omitempty"` + Assertions []Assertion `json:"assertions,omitempty"` + Retry int `json:"retry"` + JobType string `json:"jobType"` } type Header struct { diff --git a/internal/monitors/monitors_list.go b/internal/monitors/monitors_list.go index 9bc0249..91c7829 100644 --- a/internal/monitors/monitors_list.go +++ b/internal/monitors/monitors_list.go @@ -54,10 +54,10 @@ func ListMonitors(httpClient *http.Client, apiKey string) error { func GetMonitorsListCmd() *cli.Command { monitorsListCmd := cli.Command{ - Name: "list", - Usage: "List all monitors", + Name: "list", + Usage: "List all monitors", Description: "List all monitors. The list shows all your monitors attached to your workspace. It displays the ID, name, and URL of each monitor.", - UsageText: "openstatus monitors list [options]", + UsageText: "openstatus monitors list [options]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "all", diff --git a/internal/run/run.go b/internal/run/run.go index 709ef67..8752072 100644 --- a/internal/run/run.go +++ b/internal/run/run.go @@ -116,10 +116,10 @@ func MonitorTrigger(httpClient *http.Client, apiKey string, monitorId string) er func RunCmd() *cli.Command { runCmd := cli.Command{ - Name: "run", - Aliases: []string{"r"}, - Usage: "Run your synthetics tests", - UsageText: "openstatus run [options]", + Name: "run", + Aliases: []string{"r"}, + Usage: "Run your synthetics tests", + UsageText: "openstatus run [options]", Description: "Run the synthetic tests defined in the config.openstatus.yaml", Action: func(ctx context.Context, cmd *cli.Command) error { @@ -141,7 +141,6 @@ func RunCmd() *cli.Command { var wg sync.WaitGroup - for _, id := range conf.Tests.Ids { wg.Add(1) go func(id int) { diff --git a/internal/whoami/whoami.go b/internal/whoami/whoami.go index 0b9473f..2c14890 100644 --- a/internal/whoami/whoami.go +++ b/internal/whoami/whoami.go @@ -45,11 +45,11 @@ func GetWhoamiCmd(httpClient *http.Client, apiKey string) error { func WhoamiCmd() *cli.Command { whoamiCmd := cli.Command{ - Name: "whoami", - Usage: "Get your workspace information", - Aliases: []string{"w"}, - UsageText: "openstatus whoami [options]", - Description: "Get your current workspace information, display the workspace name, slug, and plan", + Name: "whoami", + Usage: "Get your workspace information", + Aliases: []string{"w"}, + UsageText: "openstatus whoami [options]", + Description: "Get your current workspace information, display the workspace name, slug, and plan", Action: func(ctx context.Context, cmd *cli.Command) error { fmt.Println("Your current workspace information") err := GetWhoamiCmd(http.DefaultClient, cmd.String("access-token")) diff --git a/openstatus-docs.1 b/openstatus-docs.1 deleted file mode 100644 index 96662f3..0000000 --- a/openstatus-docs.1 +++ /dev/null @@ -1,87 +0,0 @@ -.\" Automatically generated by Pandoc 3.7.0.2 -.\" -.TH "" "" "" "" -.SH CLI -.SH NAME -openstatus \- This is OpenStatus Command Line Interface -.SH SYNOPSIS -openstatus -.SH DESCRIPTION -OpenStatus is a command line interface for managing your monitors and -triggering your synthetics tests. -.PP -Please report any issues at -https://github.com/openstatusHQ/cli/issues/new -.PP -\f[B]Usage\f[R]: -.IP -.EX -openstatus [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...] -.EE -.SH COMMANDS -.SS monitors -Manage your monitors -.SS create -Create monitors (beta) -.RS -.PP -openstatus monitors create [options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.PP -\f[B]\(enauto\-accept, \-y\f[R]: Automatically accept the prompt -.PP -\f[B]\(enconfig\f[R]=\(lq\(lq: The configuration file containing monitor -information (default: openstatus.yaml) -.SS delete -Delete a monitor -.RS -.PP -openstatus monitors delete [MonitorID] [options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.PP -\f[B]\(enauto\-accept, \-y\f[R]: Automatically accept the prompt -.SS info -Get monitor information -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.SS list -List all monitors -.RS -.PP -openstatus monitors list [options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.PP -\f[B]\(enall\f[R]: List all monitors including inactive ones -.SS trigger -Trigger a monitor test -.RS -.PP -openstatus monitors trigger [MonitorId] [options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.SS run, r -Run your synthetics tests -.RS -.PP -openstatus run[options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token -.PP -\f[B]\(enconfig\f[R]=\(lq\(lq: The configuration file (default: -config.openstatus.yaml) -.SS whoami, w -Get your current workspace information -.RS -.PP -openstatus whoami [options] -.RE -.PP -\f[B]\(enaccess\-token, \-t\f[R]=\(lq\(lq: OpenStatus API Access Token diff --git a/openstatus-docs.md b/openstatus-docs.md deleted file mode 100644 index 0d41661..0000000 --- a/openstatus-docs.md +++ /dev/null @@ -1,91 +0,0 @@ -# CLI - -# NAME - -openstatus - This is OpenStatus Command Line Interface - -# SYNOPSIS - -openstatus - -# DESCRIPTION - -OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. - -Please report any issues at https://github.com/openstatusHQ/cli/issues/new - -**Usage**: - -``` -openstatus [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...] -``` - -# COMMANDS - -## monitors - -Manage your monitors - -### create - -Create monitors (beta) - ->openstatus monitors create [options] - -**--access-token, -t**="": OpenStatus API Access Token - -**--auto-accept, -y**: Automatically accept the prompt - -**--config**="": The configuration file containing monitor information (default: openstatus.yaml) - -### delete - -Delete a monitor - ->openstatus monitors delete [MonitorID] [options] - -**--access-token, -t**="": OpenStatus API Access Token - -**--auto-accept, -y**: Automatically accept the prompt - -### info - -Get monitor information - -**--access-token, -t**="": OpenStatus API Access Token - -### list - -List all monitors - ->openstatus monitors list [options] - -**--access-token, -t**="": OpenStatus API Access Token - -**--all**: List all monitors including inactive ones - -### trigger - -Trigger a monitor test - ->openstatus monitors trigger [MonitorId] [options] - -**--access-token, -t**="": OpenStatus API Access Token - -## run, r - -Run your synthetics tests - ->openstatus run[options] - -**--access-token, -t**="": OpenStatus API Access Token - -**--config**="": The configuration file (default: config.openstatus.yaml) - -## whoami, w - -Get your current workspace information - ->openstatus whoami [options] - -**--access-token, -t**="": OpenStatus API Access Token