-
Notifications
You must be signed in to change notification settings - Fork 25
James C CLI updates tags #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7be8677
Renamed the methods UpdateRunRequest back to UpdateRunStatusRequest a…
James-Cocker 8633a04
Initial commit for runsUpdate files in the cmd and runs folder, also …
James-Cocker 07267fd
New error messages, docs changes, main functionality working, small e…
James-Cocker b6f2420
Added unit tests, existing code passes testing and printf statements …
James-Cocker 1acd930
Removed comments
James-Cocker a1e3d89
Moved gherkin tests to use the BASEDIR, in galasa, instead of the cur…
James-Cocker 1248bea
Updated runsUpdate error codes, changed invalid tag name from DELETE …
James-Cocker e40075c
Separate validation of run name and tags into it's own function
James-Cocker 4171647
Added more validation and separated logic out into functions, along w…
James-Cocker ccbed45
Separated out shared tag commands into a util file and moved invalid …
James-Cocker d4be1df
Merge branch 'main' into JamesC-cli-updates-tags
James-Cocker f8cd5d9
Reversed error message wording
James-Cocker b4d9b16
Merge branch 'main' into JamesC-cli-updates-tags
James-Cocker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
| ## galasactl runs update | ||
|
|
||
| Update the record of an existing test run on a Galasa service. | ||
|
|
||
| ### Synopsis | ||
|
|
||
| Update the record of an existing test run on a Galasa service. | ||
|
|
||
| ``` | ||
| galasactl runs update [flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| --add-tags strings comma-separated list of tags to add | ||
| -h, --help Displays the options for the 'runs update' command. | ||
| --name string the name of the test run we want to update | ||
| --remove-tags strings comma-separated list of tags to remove | ||
James-Cocker marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ### 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 runs](galasactl_runs.md) - Manage test runs in the ecosystem | ||
|
|
||
This file contains hidden or 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 hidden or 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,143 @@ | ||
| /* | ||
| * Copyright contributors to the Galasa project | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| */ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/galasa-dev/cli/pkg/api" | ||
| "github.com/galasa-dev/cli/pkg/runs" | ||
| "github.com/galasa-dev/cli/pkg/spi" | ||
| "github.com/galasa-dev/cli/pkg/utils" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // Objective: Allow the user to do this: | ||
| // runs update --name U12345 --add-tags tag1,tag2 --remove-tags tag3 | ||
|
|
||
| // Variables set by cobra's command-line parsing. | ||
| type RunsUpdateCmdValues struct { | ||
| runName string | ||
| addTags []string | ||
| removeTags []string | ||
| } | ||
|
|
||
| type RunsUpdateCommand struct { | ||
| values *RunsUpdateCmdValues | ||
| cobraCommand *cobra.Command | ||
| } | ||
|
|
||
| func NewRunsUpdateCommand(factory spi.Factory, runsCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) (spi.GalasaCommand, error) { | ||
| cmd := new(RunsUpdateCommand) | ||
| err := cmd.init(factory, runsCommand, commsFlagSet) | ||
| return cmd, err | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
| // Public methods | ||
| // ------------------------------------------------------------------------------------------------ | ||
| func (cmd *RunsUpdateCommand) Name() string { | ||
| return COMMAND_NAME_RUNS_UPDATE | ||
| } | ||
|
|
||
| func (cmd *RunsUpdateCommand) CobraCommand() *cobra.Command { | ||
| return cmd.cobraCommand | ||
| } | ||
|
|
||
| func (cmd *RunsUpdateCommand) Values() interface{} { | ||
| return cmd.values | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
| // Private methods | ||
| // ------------------------------------------------------------------------------------------------ | ||
| func (cmd *RunsUpdateCommand) init(factory spi.Factory, runsCommand spi.GalasaCommand, commsFlagSet GalasaFlagSet) error { | ||
| var err error | ||
| cmd.values = &RunsUpdateCmdValues{} | ||
| cmd.cobraCommand, err = cmd.createCobraCommand(factory, runsCommand, commsFlagSet.Values().(*CommsFlagSetValues)) | ||
| return err | ||
| } | ||
|
|
||
| func (cmd *RunsUpdateCommand) createCobraCommand( | ||
| factory spi.Factory, | ||
| runsCommand spi.GalasaCommand, | ||
| commsFlagSetValues *CommsFlagSetValues, | ||
| ) (*cobra.Command, error) { | ||
|
|
||
| var err error | ||
|
|
||
| runsUpdateCobraCmd := &cobra.Command{ | ||
| Use: "update", | ||
| Short: "Update the record of an existing test run on a Galasa service.", | ||
| Long: "Update the record of an existing test run on a Galasa service.", | ||
| Args: cobra.NoArgs, | ||
| Aliases: []string{"runs update"}, | ||
| RunE: func(cobraCmd *cobra.Command, args []string) error { | ||
| return cmd.executeRunsUpdate(factory, commsFlagSetValues) | ||
| }, | ||
| } | ||
|
|
||
| runsUpdateCobraCmd.Flags().StringVar(&cmd.values.runName, "name", "", "the name of the test run we want to update") | ||
| runsUpdateCobraCmd.MarkFlagRequired("name") | ||
|
|
||
| runsUpdateCobraCmd.Flags().StringSliceVar(&cmd.values.addTags, "add-tags", nil, "Comma-separated list of tags to add. Multiple uses of this flag are permitted.") | ||
| runsUpdateCobraCmd.Flags().StringSliceVar(&cmd.values.removeTags, "remove-tags", nil, "Comma-separated list of tags to remove. Multiple uses of this flag are permitted.") | ||
|
|
||
| runsCommand.CobraCommand().AddCommand(runsUpdateCobraCmd) | ||
|
|
||
| return runsUpdateCobraCmd, err | ||
| } | ||
|
|
||
| func (cmd *RunsUpdateCommand) executeRunsUpdate( | ||
| factory spi.Factory, | ||
| commsFlagSetValues *CommsFlagSetValues, | ||
| ) error { | ||
|
|
||
| var err error | ||
|
|
||
| // Operations on the file system will all be relative to the current folder. | ||
| fileSystem := factory.GetFileSystem() | ||
|
|
||
| err = utils.CaptureLog(fileSystem, commsFlagSetValues.logFileName) | ||
| if err == nil { | ||
| commsFlagSetValues.isCapturingLogs = true | ||
|
|
||
| // Get the ability to query environment variables. | ||
| env := factory.GetEnvironment() | ||
|
|
||
| var galasaHome spi.GalasaHome | ||
| galasaHome, err = utils.NewGalasaHome(fileSystem, env, commsFlagSetValues.CmdParamGalasaHomePath) | ||
| if err == nil { | ||
|
|
||
| var commsClient api.APICommsClient | ||
| commsClient, err = api.NewAPICommsClient( | ||
| commsFlagSetValues.bootstrap, | ||
| commsFlagSetValues.maxRetries, | ||
| commsFlagSetValues.retryBackoffSeconds, | ||
| factory, | ||
| galasaHome, | ||
| ) | ||
|
|
||
| if err == nil { | ||
|
|
||
| var console = factory.GetStdOutConsole() | ||
| byteReader := factory.GetByteReader() | ||
| timeService := factory.GetTimeService() | ||
|
|
||
| // Call to process the command in a unit-testable way. | ||
| err = runs.RunsUpdate( | ||
| cmd.values.runName, | ||
| cmd.values.addTags, | ||
| cmd.values.removeTags, | ||
| console, | ||
| commsClient, | ||
| timeService, | ||
| byteReader, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return err | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.