// finds the non-deleted release with the given name
rel,err:=s.env.Releases.Read(req.Name)
iferr!=nil{
returnnil,err
}
//validate chart name is same as previous release
givenChart:=req.Chart.Metadata.Name
releasedChart:=rel.Chart.Metadata.Name
ifgivenChart!=releasedChart{
returnnil,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
ifgivenChartVersion<=releasedChartVersion{
returnnil,fmt.Errorf("Given chart (%s-%v) must be a higher version than released chart (%s-%v)",givenChart,givenChartVersion,releasedChart,releasedChartVersion)