Merge branch 'master' into dotenv

This commit is contained in:
Erin Call 2020-01-02 13:30:19 -08:00 committed by GitHub
commit 7ecfe70e3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 7 deletions

View file

@ -65,6 +65,7 @@ drone-helm3 is largely backwards-compatible with drone-helm. There are some know
* You'll need to migrate the deployments in the cluster [helm-v2-to-helm-v3](https://helm.sh/blog/migrate-from-helm-v2-to-helm-v3/).
* EKS is not supported. See [#5](https://github.com/pelotech/drone-helm3/issues/5) for more information.
* The `prefix` setting is no longer supported. If you were relying on the `prefix` setting with `secrets: [...]`, you'll need to switch to the `from_secret` syntax.
* During uninstallations, the release history is purged by default. Use `keep_history: true` to return to the old behavior.
* Several settings no longer have any effect. The plugin will produce warnings if any of these are present:
* `purge` -- this is the default behavior in Helm 3
* `recreate_pods`

View file

@ -55,6 +55,7 @@ Uninstallations are triggered when the `helm_command` setting is "uninstall" or
| kubernetes_token | string | yes | Token for authenticating to Kubernetes. |
| service_account | string | | Service account for authenticating to Kubernetes. Default is `helm`. |
| kubernetes_certificate | string | | Base64 encoded TLS certificate used by the Kubernetes cluster's certificate authority. |
| keep_history | boolean | | Pass `--keep-history` to `helm uninstall`, to retain the release history. |
| dry_run | boolean | | Pass `--dry-run` to `helm uninstall`. |
| timeout | duration | | Timeout for any *individual* Kubernetes operation. The uninstallation's full runtime may exceed this duration. |
| skip_tls_verify | boolean | | Connect to the Kubernetes cluster without checking for a valid TLS certificate. Not recommended in production. |

View file

@ -38,6 +38,7 @@ type Config struct {
DryRun bool `split_words:"true"` // Pass --dry-run to applicable helm commands
Wait bool `` // Pass --wait to applicable helm commands
ReuseValues bool `split_words:"true"` // Pass --reuse-values to `helm upgrade`
KeepHistory bool `split_words:"true"` // Pass --keep-history to `helm uninstall`
Timeout string `` // Argument to pass to --timeout in applicable helm commands
Chart string `` // Chart argument to use in applicable helm commands
Release string `` // Release argument to use in applicable helm commands

View file

@ -120,8 +120,9 @@ var uninstall = func(cfg Config) []Step {
steps = append(steps, depUpdate(cfg)...)
}
steps = append(steps, &run.Uninstall{
Release: cfg.Release,
DryRun: cfg.DryRun,
Release: cfg.Release,
DryRun: cfg.DryRun,
KeepHistory: cfg.KeepHistory,
})
return steps

View file

@ -198,6 +198,7 @@ func (suite *PlanTestSuite) TestUninstall() {
DryRun: true,
Timeout: "think about what you did",
Release: "jetta_id_love_to_change_the_world",
KeepHistory: true,
}
steps := uninstall(cfg)
@ -220,8 +221,9 @@ func (suite *PlanTestSuite) TestUninstall() {
suite.Require().IsType(&run.Uninstall{}, steps[1])
actual, _ := steps[1].(*run.Uninstall)
expected = &run.Uninstall{
Release: "jetta_id_love_to_change_the_world",
DryRun: true,
Release: "jetta_id_love_to_change_the_world",
DryRun: true,
KeepHistory: true,
}
suite.Equal(expected, actual)
}

View file

@ -6,9 +6,10 @@ import (
// Uninstall is an execution step that calls `helm uninstall` when executed.
type Uninstall struct {
Release string
DryRun bool
cmd cmd
Release string
DryRun bool
KeepHistory bool
cmd cmd
}
// Execute executes the `helm uninstall` command.
@ -36,6 +37,9 @@ func (u *Uninstall) Prepare(cfg Config) error {
if u.DryRun {
args = append(args, "--dry-run")
}
if u.KeepHistory {
args = append(args, "--keep-history")
}
args = append(args, u.Release)

View file

@ -81,6 +81,21 @@ func (suite *UninstallTestSuite) TestPrepareDryRunFlag() {
suite.Equal(expected, suite.actualArgs)
}
func (suite *UninstallTestSuite) TestPrepareKeepHistoryFlag() {
u := Uninstall{
Release: "perturbator_sentient",
KeepHistory: true,
}
cfg := Config{}
suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes()
suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes()
suite.NoError(u.Prepare(cfg))
expected := []string{"uninstall", "--keep-history", "perturbator_sentient"}
suite.Equal(expected, suite.actualArgs)
}
func (suite *UninstallTestSuite) TestPrepareNamespaceFlag() {
u := Uninstall{
Release: "carly_simon_run_away_with_me",