diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 4260bd914..52e5e9b2d 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -325,6 +325,16 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R return res, nil } +// reuseValues copies values from the current release to a new release if the new release does not have any values. +// +// If the request already has values, or if there are no values in the current release, this does nothing. +func (s *releaseServer) reuseValues(req *services.UpdateReleaseRequest, current *release.Release) { + if (req.Values == nil || req.Values.Raw == "") && current.Config != nil && current.Config.Raw != "" { + log.Printf("Copying values from %s (v%d) to new release.", current.Name, current.Version) + req.Values = current.Config + } +} + // prepareUpdate builds an updated release for an update operation. func (s *releaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*release.Release, *release.Release, error) { if req.Name == "" { @@ -341,6 +351,9 @@ func (s *releaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele return nil, nil, err } + // If new values were not supplied in the upgrade, re-use the existing values. + s.reuseValues(req, currentRelease) + ts := timeconv.Now() options := chartutil.ReleaseOptions{ Name: req.Name, diff --git a/cmd/tiller/release_server_test.go b/cmd/tiller/release_server_test.go index 3da3a6173..d63a52e42 100644 --- a/cmd/tiller/release_server_test.go +++ b/cmd/tiller/release_server_test.go @@ -110,7 +110,7 @@ func namedReleaseStub(name string, status release.Status_Code) *release.Release Status: &release.Status{Code: status}, }, Chart: chartStub(), - Config: &chart.Config{Raw: `name = "value"`}, + Config: &chart.Config{Raw: `name: value`}, Version: 1, Hooks: []*release.Hook{ { @@ -568,6 +568,12 @@ func TestUpdateRelease(t *testing.T) { t.Errorf("No manifest returned: %v", res.Release) } + if res.Release.Config == nil { + t.Errorf("Got release without config: %#v", res.Release) + } else if res.Release.Config.Raw != rel.Config.Raw { + t.Errorf("Expected release values %q, got %q", rel.Config.Raw, res.Release.Config.Raw) + } + if len(updated.Manifest) == 0 { t.Errorf("Expected manifest in %v", res) } diff --git a/pkg/chartutil/chartfile.go b/pkg/chartutil/chartfile.go index 3087d81d4..27b8364df 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chartutil/chartfile.go @@ -24,7 +24,9 @@ import ( "k8s.io/helm/pkg/proto/hapi/chart" ) -// APIVersionV1 is the API version number for version 1. +// ApiVersionV1 is the API version number for version 1. +// +// This is ApiVersionV1 instead of APIVersionV1 to match the protobuf-generated name. const ApiVersionV1 = "v1" // UnmarshalChartfile takes raw Chart.yaml data and unmarshals it.