Skip to content
Open
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
3 changes: 3 additions & 0 deletions ct/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func addInstallFlags(flags *flag.FlagSet) {
flags.String("helm-extra-set-args", "", heredoc.Doc(`
Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--set=name=value"`))
flags.String("helm-uninstall-extra-args", "", heredoc.Doc(`
Additional arguments for Helm uninstall. Must be passed as a single quoted string
(e.g. "--no-hooks"`))
flags.Bool("skip-clean-up", false, heredoc.Doc(`
Skip resources clean-up. Used if need to continue other flows or keep it around.`))
}
Expand Down
7 changes: 4 additions & 3 deletions doc/ct_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ ct install [flags]
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
(e.g. '--timeout 500s')
--helm-extra-set-args string Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--set=name=value"
(e.g. "--set=name=value")
--helm-uninstall-extra-args string Additional arguments for Helm uninstall. Must be passed as a single quoted string
(e.g. "--no-hooks --cascade background")
--helm-lint-extra-args string Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
(e.g. '--quiet')
--helm-repo-extra-args strings Additional arguments for the 'helm repo add' command to be
Expand Down Expand Up @@ -84,5 +86,4 @@ ct install [flags]

### SEE ALSO

* [ct](ct.md) - The Helm chart testing tool

* [ct](ct.md) - The Helm chart testing tool
3 changes: 2 additions & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ func NewTesting(config config.Configuration) (Testing, error) {
helmExtraArgs := strings.Fields(config.HelmExtraArgs)
helmExtraSetArgs := strings.Fields(config.HelmExtraSetArgs)
helmLintExtraArgs := strings.Fields(config.HelmLintExtraArgs)
helmUninstallExtraArgs := strings.Fields(config.HelmUninstallExtraArgs)

testing := Testing{
config: config,
helm: tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, helmExtraSetArgs),
helm: tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, helmExtraSetArgs, helmUninstallExtraArgs),
git: tool.NewGit(procExec),
kubectl: tool.NewKubectl(procExec, config.KubectlTimeout),
linter: tool.NewLinter(procExec),
Expand Down
3 changes: 2 additions & 1 deletion pkg/chart/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
procExec := exec.NewProcessExecutor(true)
extraArgs := strings.Fields(cfg.HelmExtraArgs)
extraLintArgs := strings.Fields(cfg.HelmLintExtraArgs)
uninstallExtraArgs := strings.Fields(cfg.HelmUninstallExtraArgs)

return Testing{
config: cfg,
Expand All @@ -43,7 +44,7 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
utils: util.Utils{},
accountValidator: fakeAccountValidator{},
linter: fakeMockLinter,
helm: tool.NewHelm(procExec, extraArgs, extraLintArgs, strings.Fields(extraSetArgs)),
helm: tool.NewHelm(procExec, extraArgs, extraLintArgs, strings.Fields(extraSetArgs), uninstallExtraArgs),
kubectl: tool.NewKubectl(procExec, 30*time.Second),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Configuration struct {
ChartDirs []string `mapstructure:"chart-dirs"`
ExcludedCharts []string `mapstructure:"excluded-charts"`
HelmExtraArgs string `mapstructure:"helm-extra-args"`
HelmUninstallExtraArgs string `mapstructure:"helm-uninstall-extra-args"`
HelmExtraSetArgs string `mapstructure:"helm-extra-set-args"`
HelmLintExtraArgs string `mapstructure:"helm-lint-extra-args"`
HelmRepoExtraArgs []string `mapstructure:"helm-repo-extra-args"`
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
require.Equal(t, []string{"common"}, cfg.ExcludedCharts)
require.Equal(t, "--timeout 300s", cfg.HelmExtraArgs)
require.Equal(t, "--quiet", cfg.HelmLintExtraArgs)
require.Equal(t, "--no-hooks --cascade background", cfg.HelmUninstallExtraArgs)
require.Equal(t, true, cfg.Upgrade)
require.Equal(t, true, cfg.SkipMissingValues)
require.Equal(t, "default", cfg.Namespace)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
"helm-extra-args": "--timeout 300s",
"helm-lint-extra-args": "--quiet",
"helm-uninstall-extra-args": "--no-hooks --cascade background",
"upgrade": true,
"skip-missing-values": true,
"namespace": "default",
Expand Down
1 change: 1 addition & 0 deletions pkg/config/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ excluded-charts:
- common
helm-extra-args: --timeout 300s
helm-lint-extra-args: --quiet
helm-uninstall-extra-args: --no-hooks --cascade background
upgrade: true
skip-missing-values: true
namespace: default
Expand Down
22 changes: 12 additions & 10 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ import (
)

type Helm struct {
exec exec.ProcessExecutor
extraArgs []string
lintExtraArgs []string
extraSetArgs []string
exec exec.ProcessExecutor
extraArgs []string
lintExtraArgs []string
extraSetArgs []string
uninstallExtraArgs []string
}

func NewHelm(exec exec.ProcessExecutor, extraArgs, lintExtraArgs, extraSetArgs []string) Helm {
func NewHelm(exec exec.ProcessExecutor, extraArgs, lintExtraArgs, extraSetArgs, uninstallExtraArgs []string) Helm {
return Helm{
exec: exec,
extraArgs: extraArgs,
lintExtraArgs: lintExtraArgs,
extraSetArgs: extraSetArgs,
exec: exec,
extraArgs: extraArgs,
lintExtraArgs: lintExtraArgs,
extraSetArgs: extraSetArgs,
uninstallExtraArgs: uninstallExtraArgs,
}
}

Expand Down Expand Up @@ -91,7 +93,7 @@ func (h Helm) Test(namespace string, release string) error {

func (h Helm) DeleteRelease(namespace string, release string) {
fmt.Printf("Deleting release %q...\n", release)
if err := h.exec.RunProcess("helm", "uninstall", release, "--namespace", namespace, "--wait", h.extraArgs); err != nil {
if err := h.exec.RunProcess("helm", "uninstall", release, "--namespace", namespace, "--wait", h.extraArgs, h.uninstallExtraArgs); err != nil {
fmt.Println("Error deleting Helm release:", err)
}
}
Expand Down