From 99c78dddde484d648692fb8e5a421bb0d734c1ec Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 10 Aug 2022 10:38:48 -0400 Subject: [PATCH] Allowing extraArgs for helm repo add --- modules/helm/options.go | 2 +- modules/helm/repo.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/helm/options.go b/modules/helm/options.go index 0d23132a8..9e2495db3 100644 --- a/modules/helm/options.go +++ b/modules/helm/options.go @@ -15,5 +15,5 @@ type Options struct { EnvVars map[string]string // Environment variables to set when running helm Version string // Version of chart Logger *logger.Logger // Set a non-default logger that should be used. See the logger package for more info. Use logger.Discard to not print the output while executing the command. - ExtraArgs map[string][]string // Extra arguments to pass to the helm install/upgrade/rollback/delete command. The key signals the command (e.g., install) while the values are the extra arguments to pass through. + ExtraArgs map[string][]string // Extra arguments to pass to the helm install/upgrade/rollback/delete and helm repo add commands. The key signals the command (e.g., install) while the values are the extra arguments to pass through. } diff --git a/modules/helm/repo.go b/modules/helm/repo.go index 6305e9273..b5b6f5349 100644 --- a/modules/helm/repo.go +++ b/modules/helm/repo.go @@ -14,7 +14,16 @@ func AddRepo(t testing.TestingT, options *Options, repoName string, repoURL stri // AddRepoE will setup the provided helm repository to the local helm client configuration. func AddRepoE(t testing.TestingT, options *Options, repoName string, repoURL string) error { - _, err := RunHelmCommandAndGetOutputE(t, options, "repo", "add", repoName, repoURL) + // Set required args + args := []string{"add", repoName, repoURL} + + // Append helm repo add ExtraArgs if available + if options.ExtraArgs != nil { + if repoAddArgs, ok := options.ExtraArgs["repoAdd"]; ok { + args = append(args, repoAddArgs...) + } + } + _, err := RunHelmCommandAndGetOutputE(t, options, "repo", args...) return err }