Skip to content

Commit

Permalink
Fix helm-extra-set-args in YAML configuration
Browse files Browse the repository at this point in the history
Currently, `helm-extra-set-args` is only available as a command-line
flag, despite being part of the config object. This does not appear to
be documented.

This changes sources the value `extraSetArgs` via the `config` object
rather than the cmd.Flags() only.
  • Loading branch information
arbourd committed Feb 7, 2025
1 parent e3ee8b5 commit b430659
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
6 changes: 1 addition & 5 deletions ct/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ func install(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("failed loading configuration: %w", err)
}

extraSetArgs, err := cmd.Flags().GetString("helm-extra-set-args")
if err != nil {
return err
}
testing, err := chart.NewTesting(*configuration, extraSetArgs)
testing, err := chart.NewTesting(*configuration)
if err != nil {
fmt.Println(err)
}
Expand Down
3 changes: 1 addition & 2 deletions ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ func lint(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("failed loading configuration: %w", err)
}

emptyExtraSetArgs := ""
testing, err := chart.NewTesting(*configuration, emptyExtraSetArgs)
testing, err := chart.NewTesting(*configuration)
if err != nil {
return err
}
Expand Down
6 changes: 1 addition & 5 deletions ct/cmd/lintAndInstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ func lintAndInstall(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("failed loading configuration: %w", err)
}

extraSetArgs, err := cmd.Flags().GetString("helm-extra-set-args")
if err != nil {
return err
}
testing, err := chart.NewTesting(*configuration, extraSetArgs)
testing, err := chart.NewTesting(*configuration)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions ct/cmd/listChanged.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func listChanged(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("failed loading configuration: %w", err)
}

emptyExtraSetArgs := ""
testing, err := chart.NewTesting(*configuration, emptyExtraSetArgs)
testing, err := chart.NewTesting(*configuration)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,15 @@ type TestResult struct {
}

// NewTesting creates a new Testing struct with the given config.
func NewTesting(config config.Configuration, extraSetArgs string) (Testing, error) {
func NewTesting(config config.Configuration) (Testing, error) {
procExec := exec.NewProcessExecutor(config.Debug)
helmExtraArgs := strings.Fields(config.HelmExtraArgs)
helmExtraSetArgs := strings.Fields(config.HelmExtraSetArgs)
helmLintExtraArgs := strings.Fields(config.HelmLintExtraArgs)

testing := Testing{
config: config,
helm: tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, strings.Fields(extraSetArgs)),
helm: tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, helmExtraSetArgs),
git: tool.NewGit(procExec),
kubectl: tool.NewKubectl(procExec, config.KubectlTimeout),
linter: tool.NewLinter(procExec),
Expand Down

0 comments on commit b430659

Please sign in to comment.