-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add galasactl secrets delete command
Signed-off-by: Eamonn Mansour <[email protected]>
- Loading branch information
Showing
17 changed files
with
917 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,27 @@ | ||
## galasactl secrets | ||
|
||
Manage secrets stored in the Galasa service's credentials store | ||
|
||
### Synopsis | ||
|
||
The parent command for operations to manipulate secrets in the Galasa service's credentials store | ||
|
||
### 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 'secrets' command. | ||
``` | ||
|
||
### 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 secrets delete](galasactl_secrets_delete.md) - Deletes a secret from the credentials store | ||
|
This file contains 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,31 @@ | ||
## galasactl secrets delete | ||
|
||
Deletes a secret from the credentials store | ||
|
||
### Synopsis | ||
|
||
Deletes a secret from the credentials store | ||
|
||
``` | ||
galasactl secrets delete [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help Displays the options for the 'secrets delete' command. | ||
--name string A mandatory flag that identifies the secret to be created or manipulated. | ||
``` | ||
|
||
### 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. | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [galasactl secrets](galasactl_secrets.md) - Manage secrets stored in the Galasa service's credentials store | ||
|
This file contains 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 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,95 @@ | ||
/* | ||
* 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 SecretsCmdValues struct { | ||
bootstrap string | ||
name string | ||
} | ||
|
||
type SecretsCommand struct { | ||
cobraCommand *cobra.Command | ||
values *SecretsCmdValues | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
// Constructors | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
func NewSecretsCmd(rootCommand spi.GalasaCommand) (spi.GalasaCommand, error) { | ||
cmd := new(SecretsCommand) | ||
err := cmd.init(rootCommand) | ||
return cmd, err | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
// Public functions | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
func (cmd *SecretsCommand) Name() string { | ||
return COMMAND_NAME_SECRETS | ||
} | ||
|
||
func (cmd *SecretsCommand) CobraCommand() *cobra.Command { | ||
return cmd.cobraCommand | ||
} | ||
|
||
func (cmd *SecretsCommand) Values() interface{} { | ||
return cmd.values | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
// Private functions | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
func (cmd *SecretsCommand) init(rootCmd spi.GalasaCommand) error { | ||
|
||
var err error | ||
|
||
cmd.values = &SecretsCmdValues{} | ||
cmd.cobraCommand, err = cmd.createCobraCommand(rootCmd) | ||
|
||
return err | ||
} | ||
|
||
func (cmd *SecretsCommand) createCobraCommand(rootCommand spi.GalasaCommand) (*cobra.Command, error) { | ||
|
||
var err error | ||
|
||
secretsCobraCmd := &cobra.Command{ | ||
Use: "secrets", | ||
Short: "Manage secrets stored in the Galasa service's credentials store", | ||
Long: "The parent command for operations to manipulate secrets in the Galasa service's credentials store", | ||
} | ||
|
||
addBootstrapFlag(secretsCobraCmd, &cmd.values.bootstrap) | ||
|
||
rootCommand.CobraCommand().AddCommand(secretsCobraCmd) | ||
|
||
return secretsCobraCmd, err | ||
} | ||
|
||
func addSecretNameFlag(cmd *cobra.Command, isMandatory bool, secretsCmdValues *SecretsCmdValues) { | ||
|
||
flagName := "name" | ||
var description string | ||
if isMandatory { | ||
description = "A mandatory flag that identifies the secret to be created or manipulated." | ||
} else { | ||
description = "An optional flag that identifies the secret to be retrieved." | ||
} | ||
|
||
cmd.Flags().StringVar(&secretsCmdValues.name, flagName, "", description) | ||
|
||
if isMandatory { | ||
cmd.MarkFlagRequired(flagName) | ||
} | ||
} |
Oops, something went wrong.