Skip to content

Commit

Permalink
Include plaintext strings
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomationD committed Sep 15, 2023
1 parent 6cf1892 commit 97d7c0e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions internal/commands/secrets_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ aws ssm get-parameters-by-path \
`

type SecretsPullOptions struct {
Config *config.Project
AppName string
Backend string
FilePath string
SecretsPath string
Force bool
Explain bool
Config *config.Project
AppName string
Backend string
FilePath string
SecretsPath string
Force bool
Explain bool
IncludeStrings bool
}

func NewSecretsPullFlags(project *config.Project) *SecretsPullOptions {
Expand Down Expand Up @@ -76,6 +77,7 @@ func NewCmdSecretsPull(project *config.Project) *cobra.Command {
cmd.Flags().StringVar(&o.SecretsPath, "path", "", "path where to store secrets (/<env>/<app> by default)")
cmd.Flags().BoolVar(&o.Explain, "explain", false, "bash alternative shown")
cmd.Flags().BoolVar(&o.Force, "force", false, "allow values overwrite")
cmd.Flags().BoolVar(&o.IncludeStrings, "include-strings", false, "include plaintext strings")

return cmd
}
Expand Down Expand Up @@ -135,6 +137,11 @@ func (o *SecretsPullOptions) pull(s *pterm.SpinnerPrinter) error {
s.UpdateText(fmt.Sprintf("Pulling secrets from %s://%s...", o.Backend, o.SecretsPath))

values := make(map[string]interface{})
typeValues := []string{"SecureString"}

if o.IncludeStrings {
typeValues = []string{"SecureString", "String"}
}

params, err := o.Config.AWSClient.SSMClient.GetParametersByPath(&ssm.GetParametersByPathInput{
Path: aws.String(o.SecretsPath),
Expand All @@ -143,7 +150,7 @@ func (o *SecretsPullOptions) pull(s *pterm.SpinnerPrinter) error {
ParameterFilters: []*ssm.ParameterStringFilter{
{
Key: aws.String("Type"),
Values: aws.StringSlice([]string{"SecureString"}),
Values: aws.StringSlice(typeValues),
},
},
})
Expand Down

0 comments on commit 97d7c0e

Please sign in to comment.