aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/all.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/all.go')
-rw-r--r--internal/rosa/all.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/rosa/all.go b/internal/rosa/all.go
index a550b7b9..ddaa1b0d 100644
--- a/internal/rosa/all.go
+++ b/internal/rosa/all.go
@@ -166,6 +166,17 @@ type Metadata struct {
//
// [Anitya]: https://release-monitoring.org/
ID int `json:"-"`
+
+ // Optional custom version checking behaviour.
+ latest func(v *Versions) string
+}
+
+// GetLatest returns the latest version described by v.
+func (meta *Metadata) GetLatest(v *Versions) string {
+ if meta.latest != nil {
+ return meta.latest(v)
+ }
+ return v.Latest
}
// Unversioned denotes an unversioned [PArtifact].
@@ -188,6 +199,14 @@ type Versions struct {
All []string `json:"versions"`
}
+// getStable returns the first Stable version, or Latest if that is unavailable.
+func (v *Versions) getStable() string {
+ if len(v.Stable) == 0 {
+ return v.Latest
+ }
+ return v.Stable[0]
+}
+
// GetVersions returns versions fetched from Anitya.
func (meta *Metadata) GetVersions(ctx context.Context) (*Versions, error) {
if meta.ID == 0 {