Skip to content
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

Add flag for disabling config printing #269

Merged
merged 4 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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