diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index ba6990ac4..ea499dd87 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -70,12 +70,15 @@ func runUpgrade(cmd *cobra.Command, args []string) error { return err } - _, err = helm.UpdateRelease(args[0], chartPath, rawVals, upgradeDryRun) + res, err := helm.UpdateRelease(args[0], chartPath, rawVals, upgradeDryRun) if err != nil { return prettyError(err) } - fmt.Println("Coming SOON to a Helm near YOU!") + newVersion := res.GetRelease().Version + fmt.Printf("I know you want to upgrade your release to version %v.\nHang tight. We're still working on the helm upgrade command.", newVersion) + + fmt.Println("\nComing soon to a Helm near YOU!") return nil } diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 4dab3952d..e1f65e770 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -174,7 +174,54 @@ func (s *releaseServer) GetReleaseContent(c ctx.Context, req *services.GetReleas } func (s *releaseServer) UpdateRelease(c ctx.Context, req *services.UpdateReleaseRequest) (*services.UpdateReleaseResponse, error) { - return nil, errNotImplemented + rel, err := s.prepareUpdate(req) + if err != nil { + return nil, err + } + + // TODO: perform update + + return &services.UpdateReleaseResponse{Release: rel}, nil +} + +// prepareUpdate builds a release for an update operation. +func (s *releaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*release.Release, error) { + if req.Name == "" { + return nil, errMissingRelease + } + + if req.Chart == nil { + return nil, errMissingChart + } + + // finds the non-deleted release with the given name + rel, err := s.env.Releases.Read(req.Name) + if err != nil { + return nil, err + } + + //validate chart name is same as previous release + givenChart := req.Chart.Metadata.Name + releasedChart := rel.Chart.Metadata.Name + if givenChart != releasedChart { + return nil, fmt.Errorf("Given chart, %s, does not match chart originally released, %s", givenChart, releasedChart) + } + + // validate new chart version is higher than old + givenChartVersion := req.Chart.Metadata.Version + releasedChartVersion := rel.Chart.Metadata.Version + if givenChartVersion <= releasedChartVersion { + return nil, fmt.Errorf("Given chart (%s-%v) must be a higher version than released chart (%s-%v)", givenChart, givenChartVersion, releasedChart, releasedChartVersion) + } + + // Store an updated release. + updatedRelease := &release.Release{ + Name: req.Name, + Chart: req.Chart, + Config: req.Values, + Version: rel.Version + 1, + } + return updatedRelease, nil } func (s *releaseServer) uniqName(start string) (string, error) {