From 8e8e59077d7555ad7b019775d44db784507a9385 Mon Sep 17 00:00:00 2001
From: Krzysztof Nazarewski <3494992+nazarewk@users.noreply.github.com>
Date: Fri, 18 Feb 2022 16:11:06 +0100
Subject: [PATCH] introduce `helm-dependency-extra-args`

addresses https://github.com/helm/chart-testing/issues/368

Signed-off-by: Krzysztof Nazarewski <3494992+nazarewk@users.noreply.github.com>
---
 ct/cmd/root.go             |   2 +
 doc/ct.md                  |   2 +-
 doc/ct_install.md          |  87 +++++++++++++--------------
 doc/ct_lint-and-install.md | 117 +++++++++++++++++++------------------
 doc/ct_lint.md             |  85 ++++++++++++++-------------
 doc/ct_list-changed.md     |   2 +-
 doc/ct_version.md          |   2 +-
 pkg/chart/chart.go         |   7 ++-
 pkg/chart/chart_test.go    |  49 ++++++++++++----
 pkg/config/config.go       |  49 ++++++++--------
 pkg/tool/helm.go           |   6 +-
 11 files changed, 225 insertions(+), 183 deletions(-)

diff --git a/ct/cmd/root.go b/ct/cmd/root.go
index 56c8609d..c792c819 100644
--- a/ct/cmd/root.go
+++ b/ct/cmd/root.go
@@ -95,6 +95,8 @@ func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
 		specified on a per-repo basis with an equals sign as delimiter
 		(e.g. 'myrepo=--username test --password secret'). May be specified
 		multiple times or separate values with commas`))
+	flags.StringSlice("helm-dependency-extra-args", []string{}, heredoc.Doc(`
+		Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]`))
 	flags.Bool("debug", false, heredoc.Doc(`
 		Print CLI calls of external tools to stdout (caution: setting this may
 		expose sensitive data when helm-repo-extra-args contains passwords)`))
diff --git a/doc/ct.md b/doc/ct.md
index b510691c..3a307c02 100644
--- a/doc/ct.md
+++ b/doc/ct.md
@@ -26,4 +26,4 @@ in given chart directories.
 * [ct list-changed](ct_list-changed.md)	 - List changed charts
 * [ct version](ct_version.md)	 - Print version information
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/doc/ct_install.md b/doc/ct_install.md
index c1fc741b..9263a690 100644
--- a/doc/ct_install.md
+++ b/doc/ct_install.md
@@ -29,52 +29,53 @@ ct install [flags]
 ### Options
 
 ```
-      --all                            Process all charts except those explicitly excluded.
-                                       Disables changed charts detection and version increment checking
-      --build-id string                An optional, arbitrary identifier that is added to the name of the namespace a
-                                       chart is installed into. In a CI environment, this could be the build number or
-                                       the ID of a pull request. If not specified, the name of the chart is used
-      --chart-dirs strings             Directories containing Helm charts. May be specified multiple times
-                                       or separate values with commas (default [charts])
-      --chart-repos strings            Additional chart repositories for dependency resolutions.
-                                       Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
-                                       May be specified multiple times or separate values with commas
-      --charts strings                 Specific charts to test. Disables changed charts detection and
-                                       version increment checking. May be specified multiple times
-                                       or separate values with commas
-      --config string                  Config file
-      --debug                          Print CLI calls of external tools to stdout (caution: setting this may
-                                       expose sensitive data when helm-repo-extra-args contains passwords)
-      --exclude-deprecated             Skip charts that are marked as deprecated
-      --excluded-charts strings        Charts that should be skipped. May be specified multiple times
-                                       or separate values with commas
-      --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"
-      --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
-                                       multiple times or separate values with commas
-  -h, --help                           help for install
-      --namespace string               Namespace to install the release(s) into. If not specified, each release will be
-                                       installed in its own randomly generated namespace
-      --print-config                   Prints the configuration to stderr (caution: setting this may
-                                       expose sensitive data when helm-repo-extra-args contains passwords)
-      --release-label string           The label to be used as a selector when inspecting resources created by charts.
-                                       This is only used if namespace is specified (default "app.kubernetes.io/instance")
-      --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-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
-      --target-branch string           The name of the target branch used to identify changed charts (default "master")
-      --upgrade                        Whether to test an in-place upgrade of each chart from its previous revision if the
-                                       current version should not introduce a breaking change according to the SemVer spec
+      --all                                  Process all charts except those explicitly excluded.
+                                             Disables changed charts detection and version increment checking
+      --build-id string                      An optional, arbitrary identifier that is added to the name of the namespace a
+                                             chart is installed into. In a CI environment, this could be the build number or
+                                             the ID of a pull request. If not specified, the name of the chart is used
+      --chart-dirs strings                   Directories containing Helm charts. May be specified multiple times
+                                             or separate values with commas (default [charts])
+      --chart-repos strings                  Additional chart repositories for dependency resolutions.
+                                             Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
+                                             May be specified multiple times or separate values with commas
+      --charts strings                       Specific charts to test. Disables changed charts detection and
+                                             version increment checking. May be specified multiple times
+                                             or separate values with commas
+      --config string                        Config file
+      --debug                                Print CLI calls of external tools to stdout (caution: setting this may
+                                             expose sensitive data when helm-repo-extra-args contains passwords)
+      --exclude-deprecated                   Skip charts that are marked as deprecated
+      --excluded-charts strings              Charts that should be skipped. May be specified multiple times
+                                             or separate values with commas
+      --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"
+      --helm-extra-set-args string           Additional arguments for Helm. Must be passed as a single quoted string
+                                             (e.g. "--set=name=value"
+      --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
+                                             multiple times or separate values with commas
+  -h, --help                                 help for install
+      --namespace string                     Namespace to install the release(s) into. If not specified, each release will be
+                                             installed in its own randomly generated namespace
+      --print-config                         Prints the configuration to stderr (caution: setting this may
+                                             expose sensitive data when helm-repo-extra-args contains passwords)
+      --release-label string                 The label to be used as a selector when inspecting resources created by charts.
+                                             This is only used if namespace is specified (default "app.kubernetes.io/instance")
+      --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-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
+      --target-branch string                 The name of the target branch used to identify changed charts (default "master")
+      --upgrade                              Whether to test an in-place upgrade of each chart from its previous revision if the
+                                             current version should not introduce a breaking change according to the SemVer spec
 ```
 
 ### SEE ALSO
 
 * [ct](ct.md)	 - The Helm chart testing tool
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/doc/ct_lint-and-install.md b/doc/ct_lint-and-install.md
index 041bbef1..47931947 100644
--- a/doc/ct_lint-and-install.md
+++ b/doc/ct_lint-and-install.md
@@ -13,67 +13,68 @@ ct lint-and-install [flags]
 ### Options
 
 ```
-      --additional-commands strings    Additional commands to run per chart (default: [])
-                                       Commands will be executed in the same order as provided in the list and will
-                                       be rendered with go template before being executed.
-                                       Example: "helm unittest --helm3 -f tests/*.yaml {{ .Path }}"
-      --all                            Process all charts except those explicitly excluded.
-                                       Disables changed charts detection and version increment checking
-      --build-id string                An optional, arbitrary identifier that is added to the name of the namespace a
-                                       chart is installed into. In a CI environment, this could be the build number or
-                                       the ID of a pull request. If not specified, the name of the chart is used
-      --chart-dirs strings             Directories containing Helm charts. May be specified multiple times
-                                       or separate values with commas (default [charts])
-      --chart-repos strings            Additional chart repositories for dependency resolutions.
-                                       Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
-                                       May be specified multiple times or separate values with commas
-      --chart-yaml-schema string       The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
-                                       is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
-                                       that order.
-      --charts strings                 Specific charts to test. Disables changed charts detection and
-                                       version increment checking. May be specified multiple times
-                                       or separate values with commas
-      --check-version-increment        Activates a check for chart version increments (default true)
-      --config string                  Config file
-      --debug                          Print CLI calls of external tools to stdout (caution: setting this may
-                                       expose sensitive data when helm-repo-extra-args contains passwords)
-      --exclude-deprecated             Skip charts that are marked as deprecated
-      --excluded-charts strings        Charts that should be skipped. May be specified multiple times
-                                       or separate values with commas
-      --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"
-      --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
-                                       multiple times or separate values with commas
-  -h, --help                           help for lint-and-install
-      --lint-conf string               The config file for YAML linting. If not specified, 'lintconf.yaml'
-                                       is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
-                                       that order
-      --namespace string               Namespace to install the release(s) into. If not specified, each release will be
-                                       installed in its own randomly generated namespace
-      --print-config                   Prints the configuration to stderr (caution: setting this may
-                                       expose sensitive data when helm-repo-extra-args contains passwords)
-      --release-label string           The label to be used as a selector when inspecting resources created by charts.
-                                       This is only used if namespace is specified (default "app.kubernetes.io/instance")
-      --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-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
-      --target-branch string           The name of the target branch used to identify changed charts (default "master")
-      --upgrade                        Whether to test an in-place upgrade of each chart from its previous revision if the
-                                       current version should not introduce a breaking change according to the SemVer spec
-      --validate-chart-schema          Enable schema validation of 'Chart.yaml' using Yamale (default true)
-      --validate-maintainers           Enable validation of maintainer account names in chart.yml.
-                                       Works for GitHub, GitLab, and Bitbucket (default true)
-      --validate-yaml                  Enable linting of 'Chart.yaml' and values files (default true)
+      --additional-commands strings          Additional commands to run per chart (default: [])
+                                             Commands will be executed in the same order as provided in the list and will
+                                             be rendered with go template before being executed.
+                                             Example: "helm unittest --helm3 -f tests/*.yaml {{ .Path }}"
+      --all                                  Process all charts except those explicitly excluded.
+                                             Disables changed charts detection and version increment checking
+      --build-id string                      An optional, arbitrary identifier that is added to the name of the namespace a
+                                             chart is installed into. In a CI environment, this could be the build number or
+                                             the ID of a pull request. If not specified, the name of the chart is used
+      --chart-dirs strings                   Directories containing Helm charts. May be specified multiple times
+                                             or separate values with commas (default [charts])
+      --chart-repos strings                  Additional chart repositories for dependency resolutions.
+                                             Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
+                                             May be specified multiple times or separate values with commas
+      --chart-yaml-schema string             The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
+                                             is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
+                                             that order.
+      --charts strings                       Specific charts to test. Disables changed charts detection and
+                                             version increment checking. May be specified multiple times
+                                             or separate values with commas
+      --check-version-increment              Activates a check for chart version increments (default true)
+      --config string                        Config file
+      --debug                                Print CLI calls of external tools to stdout (caution: setting this may
+                                             expose sensitive data when helm-repo-extra-args contains passwords)
+      --exclude-deprecated                   Skip charts that are marked as deprecated
+      --excluded-charts strings              Charts that should be skipped. May be specified multiple times
+                                             or separate values with commas
+      --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"
+      --helm-extra-set-args string           Additional arguments for Helm. Must be passed as a single quoted string
+                                             (e.g. "--set=name=value"
+      --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
+                                             multiple times or separate values with commas
+  -h, --help                                 help for lint-and-install
+      --lint-conf string                     The config file for YAML linting. If not specified, 'lintconf.yaml'
+                                             is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
+                                             that order
+      --namespace string                     Namespace to install the release(s) into. If not specified, each release will be
+                                             installed in its own randomly generated namespace
+      --print-config                         Prints the configuration to stderr (caution: setting this may
+                                             expose sensitive data when helm-repo-extra-args contains passwords)
+      --release-label string                 The label to be used as a selector when inspecting resources created by charts.
+                                             This is only used if namespace is specified (default "app.kubernetes.io/instance")
+      --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-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
+      --target-branch string                 The name of the target branch used to identify changed charts (default "master")
+      --upgrade                              Whether to test an in-place upgrade of each chart from its previous revision if the
+                                             current version should not introduce a breaking change according to the SemVer spec
+      --validate-chart-schema                Enable schema validation of 'Chart.yaml' using Yamale (default true)
+      --validate-maintainers                 Enable validation of maintainer account names in chart.yml.
+                                             Works for GitHub, GitLab, and Bitbucket (default true)
+      --validate-yaml                        Enable linting of 'Chart.yaml' and values files (default true)
 ```
 
 ### SEE ALSO
 
 * [ct](ct.md)	 - The Helm chart testing tool
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/doc/ct_lint.md b/doc/ct_lint.md
index 9c48ac4d..3b5fa3d9 100644
--- a/doc/ct_lint.md
+++ b/doc/ct_lint.md
@@ -26,51 +26,52 @@ ct lint [flags]
 ### Options
 
 ```
-      --additional-commands strings    Additional commands to run per chart (default: [])
-                                       Commands will be executed in the same order as provided in the list and will
-                                       be rendered with go template before being executed.
-                                       Example: "helm unittest --helm3 -f tests/*.yaml {{ .Path }}"
-      --all                            Process all charts except those explicitly excluded.
-                                       Disables changed charts detection and version increment checking
-      --chart-dirs strings             Directories containing Helm charts. May be specified multiple times
-                                       or separate values with commas (default [charts])
-      --chart-repos strings            Additional chart repositories for dependency resolutions.
-                                       Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
-                                       May be specified multiple times or separate values with commas
-      --chart-yaml-schema string       The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
-                                       is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
-                                       that order.
-      --charts strings                 Specific charts to test. Disables changed charts detection and
-                                       version increment checking. May be specified multiple times
-                                       or separate values with commas
-      --check-version-increment        Activates a check for chart version increments (default true)
-      --config string                  Config file
-      --debug                          Print CLI calls of external tools to stdout (caution: setting this may
-                                       expose sensitive data when helm-repo-extra-args contains passwords)
-      --exclude-deprecated             Skip charts that are marked as deprecated
-      --excluded-charts strings        Charts that should be skipped. May be specified multiple times
-                                       or separate values with commas
-      --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
-                                       multiple times or separate values with commas
-  -h, --help                           help for lint
-      --lint-conf string               The config file for YAML linting. If not specified, 'lintconf.yaml'
-                                       is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
-                                       that order
-      --print-config                   Prints the configuration to stderr (caution: setting this may
-                                       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")
-      --target-branch string           The name of the target branch used to identify changed charts (default "master")
-      --validate-chart-schema          Enable schema validation of 'Chart.yaml' using Yamale (default true)
-      --validate-maintainers           Enable validation of maintainer account names in chart.yml.
-                                       Works for GitHub, GitLab, and Bitbucket (default true)
-      --validate-yaml                  Enable linting of 'Chart.yaml' and values files (default true)
+      --additional-commands strings          Additional commands to run per chart (default: [])
+                                             Commands will be executed in the same order as provided in the list and will
+                                             be rendered with go template before being executed.
+                                             Example: "helm unittest --helm3 -f tests/*.yaml {{ .Path }}"
+      --all                                  Process all charts except those explicitly excluded.
+                                             Disables changed charts detection and version increment checking
+      --chart-dirs strings                   Directories containing Helm charts. May be specified multiple times
+                                             or separate values with commas (default [charts])
+      --chart-repos strings                  Additional chart repositories for dependency resolutions.
+                                             Repositories should be formatted as 'name=url' (ex: local=http://127.0.0.1:8879/charts).
+                                             May be specified multiple times or separate values with commas
+      --chart-yaml-schema string             The schema for chart.yml validation. If not specified, 'chart_schema.yaml'
+                                             is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
+                                             that order.
+      --charts strings                       Specific charts to test. Disables changed charts detection and
+                                             version increment checking. May be specified multiple times
+                                             or separate values with commas
+      --check-version-increment              Activates a check for chart version increments (default true)
+      --config string                        Config file
+      --debug                                Print CLI calls of external tools to stdout (caution: setting this may
+                                             expose sensitive data when helm-repo-extra-args contains passwords)
+      --exclude-deprecated                   Skip charts that are marked as deprecated
+      --excluded-charts strings              Charts that should be skipped. May be specified multiple times
+                                             or separate values with commas
+      --helm-dependency-extra-args strings   Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
+      --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
+                                             multiple times or separate values with commas
+  -h, --help                                 help for lint
+      --lint-conf string                     The config file for YAML linting. If not specified, 'lintconf.yaml'
+                                             is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
+                                             that order
+      --print-config                         Prints the configuration to stderr (caution: setting this may
+                                             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")
+      --target-branch string                 The name of the target branch used to identify changed charts (default "master")
+      --validate-chart-schema                Enable schema validation of 'Chart.yaml' using Yamale (default true)
+      --validate-maintainers                 Enable validation of maintainer account names in chart.yml.
+                                             Works for GitHub, GitLab, and Bitbucket (default true)
+      --validate-yaml                        Enable linting of 'Chart.yaml' and values files (default true)
 ```
 
 ### SEE ALSO
 
 * [ct](ct.md)	 - The Helm chart testing tool
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/doc/ct_list-changed.md b/doc/ct_list-changed.md
index e3f89e72..87c8442c 100644
--- a/doc/ct_list-changed.md
+++ b/doc/ct_list-changed.md
@@ -32,4 +32,4 @@ ct list-changed [flags]
 
 * [ct](ct.md)	 - The Helm chart testing tool
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/doc/ct_version.md b/doc/ct_version.md
index 5090b354..409e64e9 100644
--- a/doc/ct_version.md
+++ b/doc/ct_version.md
@@ -16,4 +16,4 @@ ct version [flags]
 
 * [ct](ct.md)	 - The Helm chart testing tool
 
-###### Auto generated by spf13/cobra on 16-Mar-2022
+###### Auto generated by spf13/cobra on 23-Mar-2022
diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go
index 8229e0b2..9abe2396 100644
--- a/pkg/chart/chart.go
+++ b/pkg/chart/chart.go
@@ -67,6 +67,8 @@ type Git interface {
 //
 // BuildDependencies builds the chart's dependencies
 //
+// BuildDependenciesWithArgs allows passing additional arguments to BuildDependencies
+//
 // LintWithValues runs `helm lint` for the given chart using the specified values file.
 // Pass a zero value for valuesFile in order to run lint without specifying a values file.
 //
@@ -82,6 +84,7 @@ type Git interface {
 type Helm interface {
 	AddRepo(name string, url string, extraArgs []string) error
 	BuildDependencies(chart string) error
+	BuildDependenciesWithArgs(chart string, extraArgs []string) error
 	LintWithValues(chart string, valuesFile string) error
 	InstallWithValues(chart string, valuesFile string, namespace string, release string) error
 	Upgrade(chart string, namespace string, release string) error
@@ -367,7 +370,7 @@ func (t *Testing) processCharts(action func(chart *Chart) TestResult) ([]TestRes
 		defer t.git.RemoveWorktree(worktreePath)
 
 		for _, chart := range charts {
-			if err := t.helm.BuildDependencies(t.computePreviousRevisionPath(chart.Path())); err != nil {
+			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.Println(errors.Wrapf(err, "Error building dependencies for previous revision of chart '%s'\n", chart))
 			}
@@ -375,7 +378,7 @@ func (t *Testing) processCharts(action func(chart *Chart) TestResult) ([]TestRes
 	}
 
 	for _, chart := range charts {
-		if err := t.helm.BuildDependencies(chart.Path()); err != nil {
+		if err := t.helm.BuildDependenciesWithArgs(chart.Path(), t.config.HelmDependencyExtraArgs); err != nil {
 			return nil, errors.Wrapf(err, "Error building dependencies for chart '%s'", chart)
 		}
 
diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go
index be486630..adef684d 100644
--- a/pkg/chart/chart_test.go
+++ b/pkg/chart/chart_test.go
@@ -93,23 +93,29 @@ func (l *fakeLinter) Yamale(yamlFile, schemaFile string) error {
 	return nil
 }
 
-type fakeHelm struct{}
+type fakeHelm struct {
+	mock.Mock
+}
 
-func (h fakeHelm) AddRepo(name, url string, extraArgs []string) error   { return nil }
-func (h fakeHelm) BuildDependencies(chart string) error                 { return nil }
-func (h fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil }
-func (h fakeHelm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
+func (h *fakeHelm) AddRepo(name, url string, extraArgs []string) error { return nil }
+func (h *fakeHelm) BuildDependencies(chart string) error               { return nil }
+func (h *fakeHelm) BuildDependenciesWithArgs(chart string, extraArgs []string) error {
+	h.Called(chart, extraArgs)
 	return nil
 }
-func (h fakeHelm) Upgrade(chart string, namespace string, release string) error {
+func (h *fakeHelm) LintWithValues(chart string, valuesFile string) error { return nil }
+func (h *fakeHelm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {
 	return nil
 }
-func (h fakeHelm) Test(namespace string, release string) error {
+func (h *fakeHelm) Upgrade(chart string, namespace string, release string) error {
 	return nil
 }
-func (h fakeHelm) DeleteRelease(namespace string, release string) {}
+func (h *fakeHelm) Test(namespace string, release string) error {
+	return nil
+}
+func (h *fakeHelm) DeleteRelease(namespace string, release string) {}
 
-func (h fakeHelm) Version() (string, error) {
+func (h *fakeHelm) Version() (string, error) {
 	return "v3.0.0", nil
 }
 
@@ -142,7 +148,7 @@ func newTestingMock(cfg config.Configuration) Testing {
 		chartUtils:       util.ChartUtils{},
 		accountValidator: fakeAccountValidator{},
 		linter:           fakeMockLinter,
-		helm:             fakeHelm{},
+		helm:             new(fakeHelm),
 	}
 }
 
@@ -339,6 +345,29 @@ func TestLintYamlValidation(t *testing.T) {
 	runTests(false, 0, 0)
 }
 
+func TestLintDependencyExtraArgs(t *testing.T) {
+	chart := "testdata/test_lints"
+	args := []string{"--skip-refresh"}
+
+	fakeMockHelm := new(fakeHelm)
+	ct.helm = fakeMockHelm
+	ct.config.HelmDependencyExtraArgs = args
+	ct.config.Charts = []string{chart}
+
+	t.Run("lint-helm-dependency-extra-args", func(t *testing.T) {
+		call := fakeMockHelm.On("BuildDependenciesWithArgs", chart, args).Return(nil)
+		call.Repeatability = 1
+
+		results, err := ct.LintCharts()
+		assert.Nil(t, err)
+		for _, result := range results {
+			assert.Nil(t, result.Error)
+		}
+		// -1 is set after Repeatability runs out
+		assert.Equal(t, -1, call.Repeatability)
+	})
+}
+
 func TestGenerateInstallConfig(t *testing.T) {
 	type testData struct {
 		name  string
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 466534c8..33f2acee 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -41,30 +41,31 @@ var (
 )
 
 type Configuration struct {
-	Remote                string   `mapstructure:"remote"`
-	TargetBranch          string   `mapstructure:"target-branch"`
-	Since                 string   `mapstructure:"since"`
-	BuildId               string   `mapstructure:"build-id"`
-	LintConf              string   `mapstructure:"lint-conf"`
-	ChartYamlSchema       string   `mapstructure:"chart-yaml-schema"`
-	ValidateMaintainers   bool     `mapstructure:"validate-maintainers"`
-	ValidateChartSchema   bool     `mapstructure:"validate-chart-schema"`
-	ValidateYaml          bool     `mapstructure:"validate-yaml"`
-	AdditionalCommands    []string `mapstructure:"additional-commands"`
-	CheckVersionIncrement bool     `mapstructure:"check-version-increment"`
-	ProcessAllCharts      bool     `mapstructure:"all"`
-	Charts                []string `mapstructure:"charts"`
-	ChartRepos            []string `mapstructure:"chart-repos"`
-	ChartDirs             []string `mapstructure:"chart-dirs"`
-	ExcludedCharts        []string `mapstructure:"excluded-charts"`
-	HelmExtraArgs         string   `mapstructure:"helm-extra-args"`
-	HelmRepoExtraArgs     []string `mapstructure:"helm-repo-extra-args"`
-	Debug                 bool     `mapstructure:"debug"`
-	Upgrade               bool     `mapstructure:"upgrade"`
-	SkipMissingValues     bool     `mapstructure:"skip-missing-values"`
-	Namespace             string   `mapstructure:"namespace"`
-	ReleaseLabel          string   `mapstructure:"release-label"`
-	ExcludeDeprecated     bool     `mapstructure:"exclude-deprecated"`
+	Remote                  string   `mapstructure:"remote"`
+	TargetBranch            string   `mapstructure:"target-branch"`
+	Since                   string   `mapstructure:"since"`
+	BuildId                 string   `mapstructure:"build-id"`
+	LintConf                string   `mapstructure:"lint-conf"`
+	ChartYamlSchema         string   `mapstructure:"chart-yaml-schema"`
+	ValidateMaintainers     bool     `mapstructure:"validate-maintainers"`
+	ValidateChartSchema     bool     `mapstructure:"validate-chart-schema"`
+	ValidateYaml            bool     `mapstructure:"validate-yaml"`
+	AdditionalCommands      []string `mapstructure:"additional-commands"`
+	CheckVersionIncrement   bool     `mapstructure:"check-version-increment"`
+	ProcessAllCharts        bool     `mapstructure:"all"`
+	Charts                  []string `mapstructure:"charts"`
+	ChartRepos              []string `mapstructure:"chart-repos"`
+	ChartDirs               []string `mapstructure:"chart-dirs"`
+	ExcludedCharts          []string `mapstructure:"excluded-charts"`
+	HelmExtraArgs           string   `mapstructure:"helm-extra-args"`
+	HelmRepoExtraArgs       []string `mapstructure:"helm-repo-extra-args"`
+	HelmDependencyExtraArgs []string `mapstructure:"helm-dependency-extra-args"`
+	Debug                   bool     `mapstructure:"debug"`
+	Upgrade                 bool     `mapstructure:"upgrade"`
+	SkipMissingValues       bool     `mapstructure:"skip-missing-values"`
+	Namespace               string   `mapstructure:"namespace"`
+	ReleaseLabel            string   `mapstructure:"release-label"`
+	ExcludeDeprecated       bool     `mapstructure:"exclude-deprecated"`
 }
 
 func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*Configuration, error) {
diff --git a/pkg/tool/helm.go b/pkg/tool/helm.go
index bef2454f..44afd470 100644
--- a/pkg/tool/helm.go
+++ b/pkg/tool/helm.go
@@ -39,7 +39,11 @@ func (h Helm) AddRepo(name string, url string, extraArgs []string) error {
 }
 
 func (h Helm) BuildDependencies(chart string) error {
-	return h.exec.RunProcess("helm", "dependency", "build", chart)
+	return h.BuildDependenciesWithArgs(chart, []string{})
+}
+
+func (h Helm) BuildDependenciesWithArgs(chart string, extraArgs []string) error {
+	return h.exec.RunProcess("helm", "dependency", "build", chart, extraArgs)
 }
 
 func (h Helm) LintWithValues(chart string, valuesFile string) error {