Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/docs/docs.go
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/openstatus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion docs/openstatus-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions internal/config/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ 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
Public bool `json:"public,omitempty" ,yaml:"public,omitempty"`
// 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
Expand Down
3 changes: 0 additions & 3 deletions internal/config/openstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

type Monitors map[string]Monitor



func ReadOpenStatus(path string) ([]Monitor, error) {
f := file.Provider(path)

Expand Down Expand Up @@ -39,7 +37,6 @@ func ReadOpenStatus(path string) ([]Monitor, error) {
}
}


var monitor []Monitor
for _, value := range out {
for _, assertion := range value.Assertions {
Expand Down
6 changes: 3 additions & 3 deletions internal/monitors/monitor_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 2 additions & 4 deletions internal/monitors/monitor_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/urfave/cli/v3"
)



func DeleteMonitor(httpClient *http.Client, apiKey string, monitorId string) error {

if monitorId == "" {
Expand Down Expand Up @@ -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{
Expand Down
22 changes: 11 additions & 11 deletions internal/monitors/monitor_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
})
}

Expand Down Expand Up @@ -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,
}
}
Expand All @@ -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 {
Expand All @@ -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"},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/monitors/monitor_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions internal/monitors/monitor_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
32 changes: 16 additions & 16 deletions internal/monitors/monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/monitors/monitors_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions internal/whoami/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
87 changes: 0 additions & 87 deletions openstatus-docs.1

This file was deleted.

Loading