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 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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,27 @@ The run "C1234" can be cancelled using the following command:
galasactl runs cancel --name C1234
```

## monitors get

This command can be used to get the details of monitors, like resource cleanup monitors, that are available in the Galasa service.

By default, the output of `monitors get` will be in a "summary" format. To change the output format, you can supply the `--format` flag followed by the format that you wish the output to be displayed in. For a list of supported formats, view the command's help information by running `galasactl monitors get --help`.

### Examples

To get a list of all monitors that are currently available in the Galasa service, run the following command:

```
galasactl monitors get
```

If you would like to get a specific monitor, you can supply the name of the monitor with the `--name` flag. For example, the following command can be used to get a monitor named "myCustomMonitor":

```
galasactl monitors get --name myCustomMonitor
```

For a complete list of supported parameters see [here](./docs/generated/galasactl_monitors_get.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 get monitors. Sending the get request to the Galasa service failed. Cause is {}
- GAL1219E: Failed to get monitors. Unexpected http status code {} received from the server.
- GAL1220E: Failed to get monitors. Unexpected http status code {} received from the server. Error details from the server could not be read. Cause: {}
- GAL1221E: Failed to get monitors. Unexpected http status code {} received from the server. Error details from the server are not in a valid json format. Cause: '{}'
- GAL1222E: Failed to get monitors. Unexpected http status code {} received from the server. Error details from the server are: '{}'
- GAL1223E: Failed to get monitors. 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
29 changes: 29 additions & 0 deletions docs/generated/galasactl_monitors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## 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 get](galasactl_monitors_get.md) - Get monitors from the Galasa service

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

Get monitors from the Galasa service

### Synopsis

Get a list of monitors or a specific monitor from the Galasa service

```
galasactl monitors get [flags]
```

### Options

```
--format string the output format of the returned monitors. Supported formats are: 'summary', 'yaml'. (default "summary")
-h, --help Displays the options for the 'monitors get' command.
--name string An optional flag that identifies the monitor to be retrieved 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

26 changes: 26 additions & 0 deletions pkg/cmd/commandCollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const (
COMMAND_NAME_PROJECT_CREATE = "project create"
COMMAND_NAME_LOCAL = "local"
COMMAND_NAME_LOCAL_INIT = "local init"
COMMAND_NAME_MONITORS = "monitors"
COMMAND_NAME_MONITORS_GET = "monitors get"
COMMAND_NAME_PROPERTIES = "properties"
COMMAND_NAME_PROPERTIES_GET = "properties get"
COMMAND_NAME_PROPERTIES_SET = "properties set"
Expand Down Expand Up @@ -137,6 +139,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 +436,26 @@ 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 monitorsGetCommand spi.GalasaCommand

monitorsCommand, err = NewMonitorsCmd(rootCommand, commsFlagSet)

if err == nil {
monitorsGetCommand, err = NewMonitorsGetCommand(factory, monitorsCommand, commsFlagSet)
}

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

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