Skip to content

Commit

Permalink
Add flag for disabling config printing (#269)
Browse files Browse the repository at this point in the history
By default, ct prints the config on startup. This can be problematic
because it may contain senstivie data when helm-repo-extra-args contains
passwords. The new flag enables turning off config printing and disables
it by default.

Signed-off-by: Reinhard Nägele <[email protected]>
  • Loading branch information
unguiculus authored Sep 9, 2020
1 parent 621bece commit b3899d2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion ct/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func addInstallFlags(flags *flag.FlagSet) {
func install(cmd *cobra.Command, args []string) error {
fmt.Println("Installing charts...")

configuration, err := config.LoadConfiguration(cfgFile, cmd, true)
printConfig, err := cmd.Flags().GetBool("print-config")
if err != nil {
return err
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
}
Expand Down
6 changes: 5 additions & 1 deletion ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ func addLintFlags(flags *flag.FlagSet) {
func lint(cmd *cobra.Command, args []string) error {
fmt.Println("Linting charts...")

configuration, err := config.LoadConfiguration(cfgFile, cmd, true)
printConfig, err := cmd.Flags().GetBool("print-config")
if err != nil {
return err
}
configuration, err := config.LoadConfiguration(cfgFile, cmd, printConfig)
if err != nil {
return fmt.Errorf("Error loading configuration: %s", err)
}
Expand Down
7 changes: 5 additions & 2 deletions ct/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
(e.g. 'myrepo=--username test --password secret'). May be specified
multiple times or separate values with commas`))
flags.Bool("debug", false, heredoc.Doc(`
Print CLI calls of external tools to stdout (Note: depending on helm-extra-args
passed, this may reveal sensitive data)`))
Print CLI calls of external tools to stdout (caution: setting this may
expose sensitive data when helm-repo-extra-args contains passwords)`))
flags.Bool("print-config", false, heredoc.Doc(`
Prints the configuration to stdout (caution: setting this may
expose sensitive data when helm-repo-extra-args contains passwords)`))
}
4 changes: 1 addition & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*C
return nil, errors.Wrap(err, "Error loading config file")
}
} else {
if printConfig {
fmt.Println("Using config file: ", v.ConfigFileUsed())
}
fmt.Println("Using config file:", v.ConfigFileUsed())
}

isLint := strings.Contains(cmd.Use, "lint")
Expand Down

0 comments on commit b3899d2

Please sign in to comment.