Merge pull request #4364 from michelleN/fix-4337

fix(release_server): fix how we merge values
pull/4345/merge
Michelle Noorali 6 years ago committed by GitHub
commit 2d82b88282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -138,7 +138,9 @@ func (s *ReleaseServer) reuseValues(req *services.UpdateReleaseRequest, current
} }
// merge new values with current // merge new values with current
req.Values.Raw = current.Config.Raw + "\n" + req.Values.Raw if current.Config != nil && current.Config.Raw != "" && current.Config.Raw != "{}\n" {
req.Values.Raw = current.Config.Raw + "\n" + req.Values.Raw
}
req.Chart.Values = &chart.Config{Raw: nv} req.Chart.Values = &chart.Config{Raw: nv}
// yaml unmarshal and marshal to remove duplicate keys // yaml unmarshal and marshal to remove duplicate keys

@ -129,6 +129,46 @@ func TestUpdateRelease_ResetValues(t *testing.T) {
} }
} }
func TestUpdateRelease_ReuseValuesWithNoValues(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
installReq := &services.InstallReleaseRequest{
Namespace: "spaced",
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "templates/hello", Data: []byte("hello: world")},
{Name: "templates/hooks", Data: []byte(manifestWithHook)},
},
Values: &chart.Config{Raw: "defaultFoo: defaultBar"},
},
}
installResp, err := rs.InstallRelease(c, installReq)
if err != nil {
t.Fatal(err)
}
rel := installResp.Release
req := &services.UpdateReleaseRequest{
Name: rel.Name,
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "templates/hello", Data: []byte("hello: world")},
},
},
Values: &chart.Config{Raw: ""},
ReuseValues: true,
}
_, err = rs.UpdateRelease(c, req)
if err != nil {
t.Fatalf("Failed updated: %s", err)
}
}
// This is a regression test for bug found in issue #3655 // This is a regression test for bug found in issue #3655
func TestUpdateRelease_ComplexReuseValues(t *testing.T) { func TestUpdateRelease_ComplexReuseValues(t *testing.T) {
c := helm.NewContext() c := helm.NewContext()

Loading…
Cancel
Save