From 941b1f4d68b6cf3d299df880152d90227e1a441e Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Fri, 7 Sep 2018 12:22:12 -0700 Subject: [PATCH] fix(release_server): handle the case when requested values is empty (#4604) Signed-off-by: Matthew Fisher --- pkg/tiller/release_server.go | 6 +++++- pkg/tiller/release_update_test.go | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/tiller/release_server.go b/pkg/tiller/release_server.go index e847c63fc..e913579aa 100644 --- a/pkg/tiller/release_server.go +++ b/pkg/tiller/release_server.go @@ -139,7 +139,11 @@ func (s *ReleaseServer) reuseValues(req *services.UpdateReleaseRequest, current // merge new values with current if current.Config != nil && current.Config.Raw != "" && current.Config.Raw != "{}\n" { - req.Values.Raw = current.Config.Raw + "\n" + req.Values.Raw + if req.Values.Raw != "{}\n" { + req.Values.Raw = current.Config.Raw + "\n" + req.Values.Raw + } else { + req.Values.Raw = current.Config.Raw + "\n" + } } req.Chart.Values = &chart.Config{Raw: nv} diff --git a/pkg/tiller/release_update_test.go b/pkg/tiller/release_update_test.go index 5edd53b82..1f189a8b7 100644 --- a/pkg/tiller/release_update_test.go +++ b/pkg/tiller/release_update_test.go @@ -159,12 +159,11 @@ func TestUpdateRelease_ReuseValuesWithNoValues(t *testing.T) { {Name: "templates/hello", Data: []byte("hello: world")}, }, }, - Values: &chart.Config{Raw: ""}, + Values: &chart.Config{Raw: "{}\n"}, ReuseValues: true, } - _, err = rs.UpdateRelease(c, req) - if err != nil { + if _, err := rs.UpdateRelease(c, req); err != nil { t.Fatalf("Failed updated: %s", err) } }