Skip to content

Commit

Permalink
add helm lint extra args
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Nov 1, 2023
1 parent 0cb17e5 commit a3c5eb5
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
version: v1.53
version: v1.55
5 changes: 4 additions & 1 deletion ct/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
May be specified multiple times or separate values with commas`))
flags.String("helm-extra-args", "", heredoc.Doc(`
Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--timeout 500s")`))
(e.g. '--timeout 500s')`))
flags.String("helm-lint-extra-args", "", heredoc.Doc(`
Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
(e.g. '--quiet')`))
flags.StringSlice("helm-repo-extra-args", []string{}, heredoc.Doc(`
Additional arguments for the 'helm repo add' command to be
specified on a per-repo basis with an equals sign as delimiter
Expand Down
4 changes: 3 additions & 1 deletion doc/ct_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ ct install [flags]
for command output
--helm-dependency-extra-args strings Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--timeout 500s")
(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"
--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
specified on a per-repo basis with an equals sign as delimiter
(e.g. 'myrepo=--username test --password secret'). May be specified
Expand Down
4 changes: 3 additions & 1 deletion doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ ct lint-and-install [flags]
for command output
--helm-dependency-extra-args strings Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--timeout 500s")
(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"
--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
specified on a per-repo basis with an equals sign as delimiter
(e.g. 'myrepo=--username test --password secret'). May be specified
Expand Down
4 changes: 3 additions & 1 deletion doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ ct lint [flags]
for command output
--helm-dependency-extra-args strings Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
--helm-extra-args string Additional arguments for Helm. Must be passed as a single quoted string
(e.g. "--timeout 500s")
(e.g. '--timeout 500s')
--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
specified on a per-repo basis with an equals sign as delimiter
(e.g. 'myrepo=--username test --password secret'). May be specified
Expand Down
5 changes: 3 additions & 2 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,12 @@ type TestResult struct {
// NewTesting creates a new Testing struct with the given config.
func NewTesting(config config.Configuration, extraSetArgs string) (Testing, error) {
procExec := exec.NewProcessExecutor(config.Debug)
extraArgs := strings.Fields(config.HelmExtraArgs)
helmExtraArgs := strings.Fields(config.HelmExtraArgs)
helmLintExtraArgs := strings.Fields(config.HelmLintExtraArgs)

testing := Testing{
config: config,
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
helm: tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, strings.Fields(extraSetArgs)),
git: tool.NewGit(procExec),
kubectl: tool.NewKubectl(procExec, config.KubectlTimeout),
linter: tool.NewLinter(procExec),
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Configuration struct {
ChartDirs []string `mapstructure:"chart-dirs"`
ExcludedCharts []string `mapstructure:"excluded-charts"`
HelmExtraArgs string `mapstructure:"helm-extra-args"`
HelmLintExtraArgs string `mapstructure:"helm-lint-extra-args"`
HelmRepoExtraArgs []string `mapstructure:"helm-repo-extra-args"`
HelmDependencyExtraArgs []string `mapstructure:"helm-dependency-extra-args"`
Debug bool `mapstructure:"debug"`
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
require.Equal(t, []string{"incubator=--username test"}, cfg.HelmRepoExtraArgs)
require.Equal(t, []string{"stable", "incubator"}, cfg.ChartDirs)
require.Equal(t, []string{"common"}, cfg.ExcludedCharts)
require.Equal(t, "--timeout 300", cfg.HelmExtraArgs)
require.Equal(t, "--timeout 300s", cfg.HelmExtraArgs)
require.Equal(t, "--quiet", cfg.HelmLintExtraArgs)
require.Equal(t, true, cfg.Upgrade)
require.Equal(t, true, cfg.SkipMissingValues)
require.Equal(t, "default", cfg.Namespace)
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"excluded-charts": [
"common"
],
"helm-extra-args": "--timeout 300",
"helm-extra-args": "--timeout 300s",
"helm-lint-extra-args": "--quiet",
"upgrade": true,
"skip-missing-values": true,
"namespace": "default",
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ chart-dirs:
- incubator
excluded-charts:
- common
helm-extra-args: --timeout 300
helm-extra-args: --timeout 300s
helm-lint-extra-args: --quiet
upgrade: true
skip-missing-values: true
namespace: default
Expand Down
18 changes: 10 additions & 8 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ import (
)

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

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

Expand Down Expand Up @@ -60,7 +62,7 @@ func (h Helm) LintWithValues(chart string, valuesFile string) error {
values = []string{"--values", valuesFile}
}

return h.exec.RunProcess("helm", "lint", chart, values, h.extraArgs)
return h.exec.RunProcess("helm", "lint", chart, values, h.lintExtraArgs)
}

func (h Helm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
Expand Down

0 comments on commit a3c5eb5

Please sign in to comment.