use tagcmp instead of semver
This commit is contained in:
parent
c94cc9d38e
commit
b5182d80df
|
@ -23,7 +23,7 @@ import (
|
||||||
"coopcloud.tech/abra/pkg/upstream/stack"
|
"coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
loader "coopcloud.tech/abra/pkg/upstream/stack"
|
loader "coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
"coopcloud.tech/abra/pkg/web"
|
"coopcloud.tech/abra/pkg/web"
|
||||||
"github.com/coreos/go-semver/semver"
|
"coopcloud.tech/tagcmp"
|
||||||
composetypes "github.com/docker/cli/cli/compose/types"
|
composetypes "github.com/docker/cli/cli/compose/types"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
|
@ -1029,9 +1029,15 @@ func GetRecipeVersions(recipeName string, conf *runtime.Config) (RecipeVersions,
|
||||||
// sortRecipeVersions sorts the recipe semver versions
|
// sortRecipeVersions sorts the recipe semver versions
|
||||||
func sortRecipeVersions(versions RecipeVersions) {
|
func sortRecipeVersions(versions RecipeVersions) {
|
||||||
sort.Slice(versions, func(i, j int) bool {
|
sort.Slice(versions, func(i, j int) bool {
|
||||||
version1 := semver.New(getVersionString(versions[i]))
|
version1, err := tagcmp.Parse(getVersionString(versions[i]))
|
||||||
version2 := semver.New(getVersionString(versions[j]))
|
if err != nil {
|
||||||
return version1.Compare(*version2) < 0
|
panic(err)
|
||||||
|
}
|
||||||
|
version2, err := tagcmp.Parse(getVersionString(versions[j]))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return version1.IsLessThan(version2)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,18 +1052,17 @@ func getVersionString(versionMap map[string]map[string]ServiceMeta) string {
|
||||||
|
|
||||||
// sortVersionStrings sorts a list of semver version strings
|
// sortVersionStrings sorts a list of semver version strings
|
||||||
func sortVersionStrings(versions []string) {
|
func sortVersionStrings(versions []string) {
|
||||||
semverVersions := make([]*semver.Version, len(versions))
|
sort.Slice(versions, func(i, j int) bool {
|
||||||
for i, v := range versions {
|
version1, err := tagcmp.Parse(versions[i])
|
||||||
sv, err := semver.NewVersion(v)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
semverVersions[i] = sv
|
version2, err := tagcmp.Parse(versions[j])
|
||||||
}
|
if err != nil {
|
||||||
semver.Sort(semverVersions)
|
panic(err)
|
||||||
for i, sv := range semverVersions {
|
}
|
||||||
versions[i] = sv.String()
|
return version1.IsLessThan(version2)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue.
|
// GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue.
|
||||||
|
|
Loading…
Reference in New Issue