Commit bcda0b87 authored by Matt Butcher's avatar Matt Butcher Committed by GitHub

Merge pull request #1278 from technosophos/feat/1227-reuse-values-on-upgrade

feat(tiller): re-use values during upgrade
parents d2c8a81a 3e3312ce
......@@ -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,
......
......@@ -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)
}
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment