Merge pull request #59 from pelotech/keep-history
Pass --keep-history when so instructed
This commit is contained in:
commit
d5bd083bf5
|
@ -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/).
|
* 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.
|
* 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.
|
* 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:
|
* 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
|
* `purge` -- this is the default behavior in Helm 3
|
||||||
* `recreate_pods`
|
* `recreate_pods`
|
||||||
|
|
|
@ -55,6 +55,7 @@ Uninstallations are triggered when the `helm_command` setting is "uninstall" or
|
||||||
| kubernetes_token | string | yes | Token for authenticating to Kubernetes. |
|
| kubernetes_token | string | yes | Token for authenticating to Kubernetes. |
|
||||||
| service_account | string | | Service account for authenticating to Kubernetes. Default is `helm`. |
|
| 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. |
|
| 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`. |
|
| 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. |
|
| 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. |
|
| 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
|
DryRun bool `split_words:"true"` // Pass --dry-run to applicable helm commands
|
||||||
Wait bool `` // Pass --wait to applicable helm commands
|
Wait bool `` // Pass --wait to applicable helm commands
|
||||||
ReuseValues bool `split_words:"true"` // Pass --reuse-values to `helm upgrade`
|
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
|
Timeout string `` // Argument to pass to --timeout in applicable helm commands
|
||||||
Chart string `` // Chart argument to use in applicable helm commands
|
Chart string `` // Chart argument to use in applicable helm commands
|
||||||
Release string `` // Release argument to use in applicable helm commands
|
Release string `` // Release argument to use in applicable helm commands
|
||||||
|
|
|
@ -120,8 +120,9 @@ var uninstall = func(cfg Config) []Step {
|
||||||
steps = append(steps, depUpdate(cfg)...)
|
steps = append(steps, depUpdate(cfg)...)
|
||||||
}
|
}
|
||||||
steps = append(steps, &run.Uninstall{
|
steps = append(steps, &run.Uninstall{
|
||||||
Release: cfg.Release,
|
Release: cfg.Release,
|
||||||
DryRun: cfg.DryRun,
|
DryRun: cfg.DryRun,
|
||||||
|
KeepHistory: cfg.KeepHistory,
|
||||||
})
|
})
|
||||||
|
|
||||||
return steps
|
return steps
|
||||||
|
|
|
@ -198,6 +198,7 @@ func (suite *PlanTestSuite) TestUninstall() {
|
||||||
DryRun: true,
|
DryRun: true,
|
||||||
Timeout: "think about what you did",
|
Timeout: "think about what you did",
|
||||||
Release: "jetta_id_love_to_change_the_world",
|
Release: "jetta_id_love_to_change_the_world",
|
||||||
|
KeepHistory: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
steps := uninstall(cfg)
|
steps := uninstall(cfg)
|
||||||
|
@ -220,8 +221,9 @@ func (suite *PlanTestSuite) TestUninstall() {
|
||||||
suite.Require().IsType(&run.Uninstall{}, steps[1])
|
suite.Require().IsType(&run.Uninstall{}, steps[1])
|
||||||
actual, _ := steps[1].(*run.Uninstall)
|
actual, _ := steps[1].(*run.Uninstall)
|
||||||
expected = &run.Uninstall{
|
expected = &run.Uninstall{
|
||||||
Release: "jetta_id_love_to_change_the_world",
|
Release: "jetta_id_love_to_change_the_world",
|
||||||
DryRun: true,
|
DryRun: true,
|
||||||
|
KeepHistory: true,
|
||||||
}
|
}
|
||||||
suite.Equal(expected, actual)
|
suite.Equal(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@ import (
|
||||||
|
|
||||||
// Uninstall is an execution step that calls `helm uninstall` when executed.
|
// Uninstall is an execution step that calls `helm uninstall` when executed.
|
||||||
type Uninstall struct {
|
type Uninstall struct {
|
||||||
Release string
|
Release string
|
||||||
DryRun bool
|
DryRun bool
|
||||||
cmd cmd
|
KeepHistory bool
|
||||||
|
cmd cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute executes the `helm uninstall` command.
|
// Execute executes the `helm uninstall` command.
|
||||||
|
@ -36,6 +37,9 @@ func (u *Uninstall) Prepare(cfg Config) error {
|
||||||
if u.DryRun {
|
if u.DryRun {
|
||||||
args = append(args, "--dry-run")
|
args = append(args, "--dry-run")
|
||||||
}
|
}
|
||||||
|
if u.KeepHistory {
|
||||||
|
args = append(args, "--keep-history")
|
||||||
|
}
|
||||||
|
|
||||||
args = append(args, u.Release)
|
args = append(args, u.Release)
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,21 @@ func (suite *UninstallTestSuite) TestPrepareDryRunFlag() {
|
||||||
suite.Equal(expected, suite.actualArgs)
|
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() {
|
func (suite *UninstallTestSuite) TestPrepareNamespaceFlag() {
|
||||||
u := Uninstall{
|
u := Uninstall{
|
||||||
Release: "carly_simon_run_away_with_me",
|
Release: "carly_simon_run_away_with_me",
|
||||||
|
|
Loading…
Reference in a new issue