Skip to content

Commit

Permalink
Add boolean flag 'show-secrets' to config sub command 'view'
Browse files Browse the repository at this point in the history
this new flag is added to control the revealing of secrets for the
'crc config view' command, by default the flag is set to false and
keeps the secrets, secret.

this is only added to the 'view' sub command as for 'get' and 'set'
commands users have to also mention the config name and are  aware
that they are working with a secret config

for 'view' to reveal the secrets we'll need to pass '--show-secrets'
flag, 'crc config view --show-secrets'
  • Loading branch information
anjannath committed Sep 29, 2022
1 parent 7397181 commit 98b542d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/crc/cmd/config/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const (
DefaultConfigViewFormat = "- {{.ConfigKey | printf \"%-38s\"}}: {{.ConfigValue}}"
)

var configViewFormat string
var (
configViewFormat string
showSecrets bool
)

type configViewTemplate struct {
ConfigKey string
Expand All @@ -38,6 +41,7 @@ func configViewCmd(config config.Storage) *cobra.Command {
}
configViewCmd.Flags().StringVar(&configViewFormat, "format", DefaultConfigViewFormat,
`Go template format to apply to the configuration file. For more information about Go templates, see: https://golang.org/pkg/text/template/`)
configViewCmd.Flags().BoolVar(&showSecrets, "show-secrets", false, "Show values of secret config properties")
return configViewCmd
}

Expand All @@ -55,7 +59,7 @@ func runConfigView(cfg map[string]config.SettingValue, tmpl *template.Template,
if v.IsDefault {
continue
}
if v.IsSecret {
if v.IsSecret && !showSecrets {
continue
}
viewTmplt := configViewTemplate{k, v.AsString()}
Expand Down

0 comments on commit 98b542d

Please sign in to comment.