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

Enable strict helm linting #200

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func addLintFlags(flags *flag.FlagSet) {
Enable schema validation of 'Chart.yaml' using Yamale (default: true)`))
flags.Bool("validate-yaml", true, heredoc.Doc(`
Enable linting of 'Chart.yaml' and values files (default: true)`))
flags.Bool("strict-lint", false, heredoc.Doc(`
Enable strict chart linting (default: false)`))
}

func lint(cmd *cobra.Command, args []string) error {
Expand Down
6 changes: 5 additions & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,14 @@ type TestResult struct {
func NewTesting(config config.Configuration) (Testing, error) {
procExec := exec.NewProcessExecutor(config.Debug)
extraArgs := strings.Fields(config.HelmExtraArgs)
lintArgs := []string{}
if config.StrictLint {
lintArgs = append(lintArgs, "--strict")
}

testing := Testing{
config: config,
helm: tool.NewHelm(procExec, extraArgs),
helm: tool.NewHelm(procExec, extraArgs, lintArgs),
git: tool.NewGit(procExec),
kubectl: tool.NewKubectl(procExec),
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 @@ -47,6 +47,7 @@ type Configuration struct {
ValidateMaintainers bool `mapstructure:"validate-maintainers"`
ValidateChartSchema bool `mapstructure:"validate-chart-schema"`
ValidateYaml bool `mapstructure:"validate-yaml"`
StrictLint bool `mapstructure:"strict-lint"`
CheckVersionIncrement bool `mapstructure:"check-version-increment"`
ProcessAllCharts bool `mapstructure:"all"`
Charts []string `mapstructure:"charts"`
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 @@ -42,6 +42,7 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
require.Equal(t, true, cfg.ValidateMaintainers)
require.Equal(t, true, cfg.ValidateChartSchema)
require.Equal(t, true, cfg.ValidateYaml)
require.Equal(t, true, cfg.StrictLint)
require.Equal(t, true, cfg.CheckVersionIncrement)
require.Equal(t, false, cfg.ProcessAllCharts)
require.Equal(t, []string{"incubator=https://incubator"}, cfg.ChartRepos)
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 @@ -8,6 +8,7 @@
"validate-maintainers": true,
"validate-chart-schema": true,
"validate-yaml": true,
"strict-lint": true,
"check-version-increment": true,
"all": false,
"chart-repos": [
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 @@ -7,6 +7,7 @@ github-instance: https://github.com
validate-maintainers: true
validate-chart-schema: true
validate-yaml: true
strict-lint: true
check-version-increment: true
all: false
chart-repos:
Expand Down
6 changes: 4 additions & 2 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import (
type Helm struct {
exec exec.ProcessExecutor
extraArgs []string
lintArgs []string
}

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

Expand All @@ -46,7 +48,7 @@ func (h Helm) LintWithValues(chart string, valuesFile string) error {
values = []string{"--values", valuesFile}
}

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

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