cli: overwrite chart versions during install/upgrade

* As charts receive information like the container image from
the cli it makes sense to also version the charts based on the cli
version.
* The pseudoversion is recalculated when running cmake.
* When merging changes from release branch to main,
a new commit is introduced to set the PROJECT_VERSION back
to 0.0.0, so that builds include a pseudoversion.
This commit is contained in:
Otto Bittner 2023-02-21 11:55:49 +01:00
parent 948a12461c
commit 08ee56911b
66 changed files with 131 additions and 97 deletions

View file

@ -282,6 +282,9 @@ func (i *ChartLoader) loadOperators() (helm.Release, error) {
if err != nil {
return helm.Release{}, fmt.Errorf("loading operators chart: %w", err)
}
updateVersions(chart, compatibility.EnsurePrefixV(constants.VersionInfo))
values, err := i.loadOperatorsValues()
if err != nil {
return helm.Release{}, err
@ -366,6 +369,9 @@ func (i *ChartLoader) loadConstellationServices() (helm.Release, error) {
if err != nil {
return helm.Release{}, fmt.Errorf("loading constellation-services chart: %w", err)
}
updateVersions(chart, compatibility.EnsurePrefixV(constants.VersionInfo))
values, err := i.loadConstellationServicesValues()
if err != nil {
return helm.Release{}, err
@ -513,6 +519,24 @@ func extendConstellationServicesValues(in map[string]any, config *config.Config,
return nil
}
// updateVersions changes all versions of direct dependencies that are set to "0.0.0" to newVersion.
func updateVersions(chart *chart.Chart, newVersion string) {
chart.Metadata.Version = newVersion
selectedDeps := chart.Metadata.Dependencies
for i := range selectedDeps {
if selectedDeps[i].Version == "0.0.0" {
selectedDeps[i].Version = newVersion
}
}
deps := chart.Dependencies()
for i := range deps {
if deps[i].Metadata.Version == "0.0.0" {
deps[i].Metadata.Version = newVersion
}
}
}
// marshalChart takes a Chart object, packages it to a temporary file and returns the content of that file.
// We currently need to take this approach of marshaling as dependencies are not marshaled correctly with json.Marshal.
// This stems from the fact that chart.Chart does not export the dependencies property.