From 7b2a95e83ce30be98aac242661e0c407c97c5e5a Mon Sep 17 00:00:00 2001 From: Henno Schooljan Date: Sat, 30 May 2020 07:27:40 +0200 Subject: [PATCH] fix: Allow unsetting the last remaining values file (#3644) (#3645) * fix: Allow unsetting the last values file (#3644) Because the `setHelmOpt()` function does not act on empty inputs, it would do nothing when removing the last values file using `argocd app unset`. The parameter overrides are actually being unset correctly, so this has been changed to work the same way by manipulating `app.Spec.Source.Helm` directly. This fixes #3644. * fix: Allow unsetting the last values file, add tests * Retrigger CI pipeline --- test/e2e/helm_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 17c7900bf9..ce163f46d0 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -123,6 +123,34 @@ func TestHelmValues(t *testing.T) { }) } +func TestHelmValuesMultipleUnset(t *testing.T) { + Given(t). + Path("helm"). + When(). + AddFile("foo.yml", ""). + AddFile("baz.yml", ""). + Create(). + AppSet("--values", "foo.yml", "--values", "baz.yml"). + Then(). + And(func(app *Application) { + assert.NotNil(t, app.Spec.Source.Helm) + assert.Equal(t, []string{"foo.yml", "baz.yml"}, app.Spec.Source.Helm.ValueFiles) + }). + When(). + AppUnSet("--values", "foo.yml"). + Then(). + And(func(app *Application) { + assert.NotNil(t, app.Spec.Source.Helm) + assert.Equal(t, []string{"baz.yml"}, app.Spec.Source.Helm.ValueFiles) + }). + When(). + AppUnSet("--values", "baz.yml"). + Then(). + And(func(app *Application) { + assert.Nil(t, app.Spec.Source.Helm) + }) +} + func TestHelmValuesLiteralFileLocal(t *testing.T) { Given(t). Path("helm").