fix(version): semver version ordering #293
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user