diff --git a/docs/parameter_reference.md b/docs/parameter_reference.md index 129586b..773ca9f 100644 --- a/docs/parameter_reference.md +++ b/docs/parameter_reference.md @@ -6,7 +6,7 @@ | mode | string | helm_command | Indicates the operation to perform. Recommended, but not required. Valid options are `upgrade`, `uninstall`, `lint`, and `help`. | | update_dependencies | boolean | | Calls `helm dependency update` before running the main command.| | add_repos | list\ | helm_repos | Calls `helm repo add $repo` before running the main command. Each string should be formatted as `repo_name=https://repo.url/`. | -| repo_ca_file | string | | TLS certificate for a chart repository certificate authority. Only applicable when using `add_repos`. | +| repo_ca_file | string | | TLS certificate for a chart repository certificate authority. | | namespace | string | | Kubernetes namespace to use for this operation. | | debug | boolean | | Generate debug output within drone-helm3 and pass `--debug` to all helm commands. Use with care, since the debug output may include secrets. | diff --git a/internal/helm/plan.go b/internal/helm/plan.go index 6023c1e..2475734 100644 --- a/internal/helm/plan.go +++ b/internal/helm/plan.go @@ -111,6 +111,7 @@ var upgrade = func(cfg Config) []Step { Force: cfg.Force, Atomic: cfg.AtomicUpgrade, CleanupOnFail: cfg.CleanupOnFail, + CAFile: cfg.RepoCAFile, }) return steps diff --git a/internal/helm/plan_test.go b/internal/helm/plan_test.go index 1a6b4f3..f59fa01 100644 --- a/internal/helm/plan_test.go +++ b/internal/helm/plan_test.go @@ -143,6 +143,7 @@ func (suite *PlanTestSuite) TestUpgrade() { Force: true, AtomicUpgrade: true, CleanupOnFail: true, + RepoCAFile: "state_licensure.repo.cert", } steps := upgrade(cfg) @@ -166,6 +167,7 @@ func (suite *PlanTestSuite) TestUpgrade() { Force: cfg.Force, Atomic: true, CleanupOnFail: true, + CAFile: "state_licensure.repo.cert", } suite.Equal(expected, upgrade) diff --git a/internal/run/upgrade.go b/internal/run/upgrade.go index c239807..41c8ab0 100644 --- a/internal/run/upgrade.go +++ b/internal/run/upgrade.go @@ -20,6 +20,7 @@ type Upgrade struct { Force bool Atomic bool CleanupOnFail bool + CAFile string cmd cmd } @@ -82,6 +83,9 @@ func (u *Upgrade) Prepare(cfg Config) error { for _, vFile := range u.ValuesFiles { args = append(args, "--values", vFile) } + if u.CAFile != "" { + args = append(args, "--ca-file", u.CAFile) + } args = append(args, u.Release, u.Chart) u.cmd = command(helmBin, args...) diff --git a/internal/run/upgrade_test.go b/internal/run/upgrade_test.go index 886fb3b..bcc950c 100644 --- a/internal/run/upgrade_test.go +++ b/internal/run/upgrade_test.go @@ -102,6 +102,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() { Force: true, Atomic: true, CleanupOnFail: true, + CAFile: "local_ca.cert", } cfg := Config{} @@ -121,6 +122,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() { "--set-string", "height=5ft10in", "--values", "/usr/local/stats", "--values", "/usr/local/grades", + "--ca-file", "local_ca.cert", "maroon_5_memories", "hot_ac"}, args) return suite.mockCmd