diff --git a/catalogue/catalogue.go b/catalogue/catalogue.go index 144ab06c..b33b1fba 100644 --- a/catalogue/catalogue.go +++ b/catalogue/catalogue.go @@ -12,8 +12,10 @@ import ( "coopcloud.tech/abra/config" "coopcloud.tech/abra/web" + "coopcloud.tech/tagcmp" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" + "github.com/sirupsen/logrus" ) type Image struct { @@ -111,12 +113,21 @@ func (a App) EnsureVersion(version string) error { // LatestVersion returns the latest version of the app func (a App) LatestVersion() string { - var latestVersion string + var latestTag tagcmp.Tag for tag := range a.Versions { - // apps.json versions are sorted so the last key is latest - latestVersion = tag + currentTag, err := tagcmp.Parse(tag) + if err != nil { + logrus.Warn(fmt.Errorf("%s is not a valid tag: %s", tag, err)) + } + if latestTag == (tagcmp.Tag{}) { + latestTag = currentTag + } else { + if latestTag.IsLessThan(currentTag) { + latestTag = currentTag + } + } } - return latestVersion + return latestTag.String() } type Name = string