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"
|
||||
loader "coopcloud.tech/abra/pkg/upstream/stack"
|
||||
"coopcloud.tech/abra/pkg/web"
|
||||
"github.com/coreos/go-semver/semver"
|
||||
"coopcloud.tech/tagcmp"
|
||||
composetypes "github.com/docker/cli/cli/compose/types"
|
||||
"github.com/docker/distribution/reference"
|
||||
"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
|
||||
func sortRecipeVersions(versions RecipeVersions) {
|
||||
sort.Slice(versions, func(i, j int) bool {
|
||||
version1 := semver.New(getVersionString(versions[i]))
|
||||
version2 := semver.New(getVersionString(versions[j]))
|
||||
return version1.Compare(*version2) < 0
|
||||
version1, err := tagcmp.Parse(getVersionString(versions[i]))
|
||||
if err != nil {
|
||||
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
|
||||
func sortVersionStrings(versions []string) {
|
||||
semverVersions := make([]*semver.Version, len(versions))
|
||||
for i, v := range versions {
|
||||
sv, err := semver.NewVersion(v)
|
||||
sort.Slice(versions, func(i, j int) bool {
|
||||
version1, err := tagcmp.Parse(versions[i])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
semverVersions[i] = sv
|
||||
}
|
||||
semver.Sort(semverVersions)
|
||||
for i, sv := range semverVersions {
|
||||
versions[i] = sv.String()
|
||||
}
|
||||
version2, err := tagcmp.Parse(versions[j])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return version1.IsLessThan(version2)
|
||||
})
|
||||
}
|
||||
|
||||
// GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue.
|
||||
|
|
Loading…
Reference in New Issue