Pass --keep-history when so instructed [#24]
This commit is contained in:
parent
7d750f097d
commit
17724e7015
|
@ -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`
|
||||
|
|
|
@ -54,6 +54,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. |
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -122,6 +122,7 @@ var uninstall = func(cfg Config) []Step {
|
|||
steps = append(steps, &run.Uninstall{
|
||||
Release: cfg.Release,
|
||||
DryRun: cfg.DryRun,
|
||||
KeepHistory: cfg.KeepHistory,
|
||||
})
|
||||
|
||||
return steps
|
||||
|
|
|
@ -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)
|
||||
|
@ -222,6 +223,7 @@ func (suite *PlanTestSuite) TestUninstall() {
|
|||
expected = &run.Uninstall{
|
||||
Release: "jetta_id_love_to_change_the_world",
|
||||
DryRun: true,
|
||||
KeepHistory: true,
|
||||
}
|
||||
suite.Equal(expected, actual)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
type Uninstall struct {
|
||||
Release string
|
||||
DryRun bool
|
||||
KeepHistory bool
|
||||
cmd cmd
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue