Skip to content

Commit

Permalink
add option to skip run helm dependency build command
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato committed Nov 4, 2024
1 parent 80c0af6 commit a6947de
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func addLintFlags(flags *flag.FlagSet) {
Enable schema validation of 'Chart.yaml' using Yamale`))
flags.Bool("validate-yaml", true, heredoc.Doc(`
Enable linting of 'Chart.yaml' and values files`))
flags.Bool("skip-helm-dependencies", false, heredoc.Doc(`
Skip running 'helm dependency build' before linting`))
flags.StringSlice("additional-commands", []string{}, heredoc.Doc(`
Additional commands to run per chart (default: [])
Commands will be executed in the same order as provided in the list and will
Expand Down
1 change: 1 addition & 0 deletions doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ct lint-and-install [flags]
--remote string The name of the Git remote used to identify changed charts (default "origin")
--since string The Git reference used to identify changed charts (default "HEAD")
--skip-clean-up Skip resources clean-up. Used if need to continue other flows or keep it around.
--skip-helm-dependencies Skip running 'helm dependency build' before linting
--skip-missing-values When --upgrade has been passed, this flag will skip testing CI values files from the
previous chart revision if they have been deleted or renamed at the current chart
revision
Expand Down
1 change: 1 addition & 0 deletions doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ct lint [flags]
expose sensitive data when helm-repo-extra-args contains passwords)
--remote string The name of the Git remote used to identify changed charts (default "origin")
--since string The Git reference used to identify changed charts (default "HEAD")
--skip-helm-dependencies Skip running 'helm dependency build' before linting
--target-branch string The name of the target branch used to identify changed charts (default "main")
--use-helmignore Use .helmignore when identifying changed charts
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default true)
Expand Down
16 changes: 10 additions & 6 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,21 @@ func (t *Testing) processCharts(action func(chart *Chart) TestResult) ([]TestRes
}
defer t.git.RemoveWorktree(worktreePath) // nolint: errcheck

for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(t.computePreviousRevisionPath(chart.Path()), t.config.HelmDependencyExtraArgs); err != nil {
// Only print error (don't exit) if building dependencies for previous revision fails.
fmt.Printf("failed building dependencies for previous revision of chart %q: %v\n", chart, err.Error())
if !t.config.SkipHelmDependencies {
for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(t.computePreviousRevisionPath(chart.Path()), t.config.HelmDependencyExtraArgs); err != nil {
// Only print error (don't exit) if building dependencies for previous revision fails.
fmt.Printf("failed building dependencies for previous revision of chart %q: %v\n", chart, err.Error())
}
}
}
}

for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(chart.Path(), t.config.HelmDependencyExtraArgs); err != nil {
return nil, fmt.Errorf("failed building dependencies for chart %q: %w", chart, err)
if !t.config.SkipHelmDependencies {
if err := t.helm.BuildDependenciesWithArgs(chart.Path(), t.config.HelmDependencyExtraArgs); err != nil {
return nil, fmt.Errorf("failed building dependencies for chart %q: %w", chart, err)
}
}

result := action(chart)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Configuration struct {
ValidateMaintainers bool `mapstructure:"validate-maintainers"`
ValidateChartSchema bool `mapstructure:"validate-chart-schema"`
ValidateYaml bool `mapstructure:"validate-yaml"`
SkipHelmDependencies bool `mapstructure:"skip-helm-dependencies"`
AdditionalCommands []string `mapstructure:"additional-commands"`
CheckVersionIncrement bool `mapstructure:"check-version-increment"`
ProcessAllCharts bool `mapstructure:"all"`
Expand Down

0 comments on commit a6947de

Please sign in to comment.