fix(version): semver version ordering #293

Merged
moritz merged 3 commits from fix_version_sort into main 2023-04-26 06:38:18 +00:00
Showing only changes of commit c94cc9d38e - Show all commits

View File

@ -1043,6 +1043,23 @@ func getVersionString(versionMap map[string]map[string]ServiceMeta) string {
}
return ""
}
// sortVersionStrings sorts a list of semver version strings
func sortVersionStrings(versions []string) {
semverVersions := make([]*semver.Version, len(versions))
for i, v := range versions {
sv, err := semver.NewVersion(v)
if err != nil {
panic(err)
}
semverVersions[i] = sv
}
semver.Sort(semverVersions)
for i, sv := range semverVersions {
versions[i] = sv.String()
}
}
// GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue.
func GetRecipeCatalogueVersions(recipeName string, catl RecipeCatalogue) ([]string, error) {
var versions []string
@ -1054,7 +1071,7 @@ func GetRecipeCatalogueVersions(recipeName string, catl RecipeCatalogue) ([]stri
}
}
}
sortVersionStrings(versions)
return versions, nil
}