Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,33 @@ The run "C1234" can be cancelled using the following command:
galasactl runs cancel --name C1234
```

## monitors enable

This command can be used to enable a monitor in the Galasa service. The name of the monitor to be enabled must be provided using the `--name` flag.

### Examples

To enable a monitor named "myCustomMonitor":

```
galasactl monitors enable --name myCustomMonitor
```

For a complete list of supported parameters see [here](./docs/generated/galasactl_monitors_enable.md).

## monitors disable

This command can be used to disable a monitor in the Galasa service. The name of the monitor to be disabled must be provided using the `--name` flag.

### Examples

To disable a monitor named "myCustomMonitor":

```
galasactl monitors disable --name myCustomMonitor
```

For a complete list of supported parameters see [here](./docs/generated/galasactl_monitors_disable.md).

## properties get
This command retrieves details of properties in a namespace.
Expand Down
9 changes: 8 additions & 1 deletion docs/generated/errors-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,14 @@ The `galasactl` tool can generate the following errors:
- GAL1215E: An attempt to update a user '{}' failed. Unexpected http status code {} received from the server. Error details from the server are not in a valid json format. Cause: '{}'
- GAL1216E: An attempt to update a user '{}' failed. Unexpected http status code {} received from the server. Error details from the server are: '{}'
- GAL1217E: An attempt to update a user '{}' failed. Unexpected http status code {} received from the server. Error details from the server are not in the json format.
- GAL1225E: Failed to open file '{}' cause: {}. Check that this file exists, and that you have read permissions.
- GAL1218E: Failed to update a monitor named '{}'. Sending the put request to the Galasa service failed. Cause is {}
- GAL1219E: Failed to update a monitor named '{}'. Unexpected http status code {} received from the server.
- GAL1220E: Failed to update a monitor named '{}'. Unexpected http status code {} received from the server. Error details from the server could not be read. Cause: {}
- GAL1221E: Failed to update a monitor named '{}'. Unexpected http status code {} received from the server. Error details from the server are not in a valid json format. Cause: '{}'
- GAL1222E: Failed to update a monitor named '{}'. Unexpected http status code {} received from the server. Error details from the server are: '{}'
- GAL1223E: Failed to update a monitor named '{}'. Unexpected http status code {} received from the server. Error details from the server are not in the json format.
- GAL1224E: Galasa Monitor named {} is not known on the Galasa service.
- GAL1225E: Invalid monitor name provided. The name provided with the --name flag cannot be empty and must only contain characters in the following ranges: 'a'-'z', 'A'-'Z', '0'-'9', '-' (dash), '_' (underscore).
- GAL1226E: Internal failure. Contents of gzip could be read, but not decoded. New gzip reader failed: file: {} error: {}
- GAL1227E: Internal failure. Contents of gzip could not be decoded. {} error: {}
- GAL1228E: Internal failure. Contents of gzip could not be encoded and compressed. {} error: {}
Expand Down
1 change: 1 addition & 0 deletions docs/generated/galasactl.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A tool for controlling Galasa resources using the command-line.

* [galasactl auth](galasactl_auth.md) - Manages authentication with a Galasa ecosystem
* [galasactl local](galasactl_local.md) - Manipulate local system
* [galasactl monitors](galasactl_monitors.md) - Manage monitors in the Galasa service
* [galasactl project](galasactl_project.md) - Manipulate local project source code
* [galasactl properties](galasactl_properties.md) - Manages properties in an ecosystem
* [galasactl resources](galasactl_resources.md) - Manages resources in an ecosystem
Expand Down
30 changes: 30 additions & 0 deletions docs/generated/galasactl_monitors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## galasactl monitors

Manage monitors in the Galasa service

### Synopsis

The parent command for operations to manipulate monitors in the Galasa service

### Options

```
-b, --bootstrap string Bootstrap URL. Should start with 'http://' or 'file://'. If it starts with neither, it is assumed to be a fully-qualified path. If missing, it defaults to use the 'bootstrap.properties' file in your GALASA_HOME. Example: http://example.com/bootstrap, file:///user/myuserid/.galasa/bootstrap.properties , file://C:/Users/myuserid/.galasa/bootstrap.properties
-h, --help Displays the options for the 'monitors' command.
--rate-limit-retries int The maximum number of retries that should be made when requests to the Galasa Service fail due to rate limits being exceeded. Must be a whole number. Defaults to 3 retries (default 3)
--rate-limit-retry-backoff-secs float The amount of time in seconds to wait before retrying a command if it failed due to rate limits being exceeded. Defaults to 1 second. (default 1)
```

### Options inherited from parent commands

```
--galasahome string Path to a folder where Galasa will read and write files and configuration settings. The default is '${HOME}/.galasa'. This overrides the GALASA_HOME environment variable which may be set instead.
-l, --log string File to which log information will be sent. Any folder referred to must exist. An existing file will be overwritten. Specify "-" to log to stderr. Defaults to not logging.
```

### SEE ALSO

* [galasactl](galasactl.md) - CLI for Galasa
* [galasactl monitors disable](galasactl_monitors_disable.md) - Disable a monitor in the Galasa service
* [galasactl monitors enable](galasactl_monitors_enable.md) - Enable a monitor in the Galasa service

33 changes: 33 additions & 0 deletions docs/generated/galasactl_monitors_disable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## galasactl monitors disable

Disable a monitor in the Galasa service

### Synopsis

Disables a monitor with the given name in the Galasa service

```
galasactl monitors disable [flags]
```

### Options

```
-h, --help Displays the options for the 'monitors disable' command.
--name string A mandatory flag that identifies the monitor to be manipulated by name.
```

### Options inherited from parent commands

```
-b, --bootstrap string Bootstrap URL. Should start with 'http://' or 'file://'. If it starts with neither, it is assumed to be a fully-qualified path. If missing, it defaults to use the 'bootstrap.properties' file in your GALASA_HOME. Example: http://example.com/bootstrap, file:///user/myuserid/.galasa/bootstrap.properties , file://C:/Users/myuserid/.galasa/bootstrap.properties
--galasahome string Path to a folder where Galasa will read and write files and configuration settings. The default is '${HOME}/.galasa'. This overrides the GALASA_HOME environment variable which may be set instead.
-l, --log string File to which log information will be sent. Any folder referred to must exist. An existing file will be overwritten. Specify "-" to log to stderr. Defaults to not logging.
--rate-limit-retries int The maximum number of retries that should be made when requests to the Galasa Service fail due to rate limits being exceeded. Must be a whole number. Defaults to 3 retries (default 3)
--rate-limit-retry-backoff-secs float The amount of time in seconds to wait before retrying a command if it failed due to rate limits being exceeded. Defaults to 1 second. (default 1)
```

### SEE ALSO

* [galasactl monitors](galasactl_monitors.md) - Manage monitors in the Galasa service

33 changes: 33 additions & 0 deletions docs/generated/galasactl_monitors_enable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## galasactl monitors enable

Enable a monitor in the Galasa service

### Synopsis

Enables a monitor with the given name in the Galasa service

```
galasactl monitors enable [flags]
```

### Options

```
-h, --help Displays the options for the 'monitors enable' command.
--name string A mandatory flag that identifies the monitor to be manipulated by name.
```

### Options inherited from parent commands

```
-b, --bootstrap string Bootstrap URL. Should start with 'http://' or 'file://'. If it starts with neither, it is assumed to be a fully-qualified path. If missing, it defaults to use the 'bootstrap.properties' file in your GALASA_HOME. Example: http://example.com/bootstrap, file:///user/myuserid/.galasa/bootstrap.properties , file://C:/Users/myuserid/.galasa/bootstrap.properties
--galasahome string Path to a folder where Galasa will read and write files and configuration settings. The default is '${HOME}/.galasa'. This overrides the GALASA_HOME environment variable which may be set instead.
-l, --log string File to which log information will be sent. Any folder referred to must exist. An existing file will be overwritten. Specify "-" to log to stderr. Defaults to not logging.
--rate-limit-retries int The maximum number of retries that should be made when requests to the Galasa Service fail due to rate limits being exceeded. Must be a whole number. Defaults to 3 retries (default 3)
--rate-limit-retry-backoff-secs float The amount of time in seconds to wait before retrying a command if it failed due to rate limits being exceeded. Defaults to 1 second. (default 1)
```

### SEE ALSO

* [galasactl monitors](galasactl_monitors.md) - Manage monitors in the Galasa service

30 changes: 30 additions & 0 deletions pkg/cmd/commandCollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const (
COMMAND_NAME_PROJECT_CREATE = "project create"
COMMAND_NAME_LOCAL = "local"
COMMAND_NAME_LOCAL_INIT = "local init"
COMMAND_NAME_MONITORS = "monitors"
COMMAND_NAME_MONITORS_ENABLE = "monitors enable"
COMMAND_NAME_MONITORS_DISABLE = "monitors disable"
COMMAND_NAME_PROPERTIES = "properties"
COMMAND_NAME_PROPERTIES_GET = "properties get"
COMMAND_NAME_PROPERTIES_SET = "properties set"
Expand Down Expand Up @@ -137,6 +140,10 @@ func (commands *commandCollectionImpl) init(factory spi.Factory) error {
err = commands.addLocalCommands(factory, rootCommand)
}

if err == nil {
err = commands.addMonitorsCommands(factory, rootCommand, commsFlagSet)
}

if err == nil {
err = commands.addProjectCommands(factory, rootCommand)
}
Expand Down Expand Up @@ -430,6 +437,29 @@ func (commands *commandCollectionImpl) addSecretsCommands(factory spi.Factory, r
return err
}

func (commands *commandCollectionImpl) addMonitorsCommands(factory spi.Factory, rootCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) error {

var err error
var monitorsCommand spi.GalasaCommand
var monitorsEnableCommand spi.GalasaCommand
var monitorsDisableCommand spi.GalasaCommand

monitorsCommand, err = NewMonitorsCmd(rootCommand, commsFlagSet)

if err == nil {
monitorsEnableCommand, err = NewMonitorsEnableCommand(factory, monitorsCommand, commsFlagSet)
monitorsDisableCommand, err = NewMonitorsDisableCommand(factory, monitorsCommand, commsFlagSet)
}

if err == nil {
commands.commandMap[monitorsCommand.Name()] = monitorsCommand
commands.commandMap[monitorsEnableCommand.Name()] = monitorsEnableCommand
commands.commandMap[monitorsDisableCommand.Name()] = monitorsDisableCommand
}

return err
}

func (commands *commandCollectionImpl) addUsersCommands(factory spi.Factory, rootCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) error {

var err error
Expand Down
93 changes: 93 additions & 0 deletions pkg/cmd/monitors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright contributors to the Galasa project
*
* SPDX-License-Identifier: EPL-2.0
*/
package cmd

import (
"github.com/galasa-dev/cli/pkg/spi"
"github.com/spf13/cobra"
)

type MonitorsCmdValues struct {
name string
}

type MonitorsCommand struct {
cobraCommand *cobra.Command
values *MonitorsCmdValues
}

// ------------------------------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------------------------------

func NewMonitorsCmd(rootCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) (spi.GalasaCommand, error) {
cmd := new(MonitorsCommand)
err := cmd.init(rootCommand, commsFlagSet)
return cmd, err
}

// ------------------------------------------------------------------------------------------------
// Public functions
// ------------------------------------------------------------------------------------------------

func (cmd *MonitorsCommand) Name() string {
return COMMAND_NAME_MONITORS
}

func (cmd *MonitorsCommand) CobraCommand() *cobra.Command {
return cmd.cobraCommand
}

func (cmd *MonitorsCommand) Values() interface{} {
return cmd.values
}

// ------------------------------------------------------------------------------------------------
// Private functions
// ------------------------------------------------------------------------------------------------

func (cmd *MonitorsCommand) init(rootCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) error {

var err error

cmd.values = &MonitorsCmdValues{}
cmd.cobraCommand, err = cmd.createCobraCommand(rootCommand, commsFlagSet)

return err
}

func (cmd *MonitorsCommand) createCobraCommand(rootCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) (*cobra.Command, error) {

var err error

monitorsCobraCmd := &cobra.Command{
Use: "monitors",
Short: "Manage monitors in the Galasa service",
Long: "The parent command for operations to manipulate monitors in the Galasa service",
}

monitorsCobraCmd.PersistentFlags().AddFlagSet(commsFlagSet.Flags())
rootCommand.CobraCommand().AddCommand(monitorsCobraCmd)

return monitorsCobraCmd, err
}

func addMonitorNameFlag(cmd *cobra.Command, isMandatory bool, monitorsCmdValues *MonitorsCmdValues) {

flagName := "name"
var description string
if isMandatory {
description = "A mandatory flag that identifies the monitor to be manipulated by name."
} else {
description = "An optional flag that identifies the monitor to be retrieved by name."
}

cmd.Flags().StringVar(&monitorsCmdValues.name, flagName, "", description)

if isMandatory {
cmd.MarkFlagRequired(flagName)
}
}
Loading
Loading