Skip to content

Commit

Permalink
Update go-version to support wildcards.
Browse files Browse the repository at this point in the history
  • Loading branch information
beornf committed Apr 3, 2023
1 parent 8a1a87e commit ac70c65
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.18

require (
github.com/ake-persson/mapslice-json v0.0.0-20210720081907-22c8edf57807
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492
github.com/bmatcuk/doublestar v1.3.4
github.com/cloudingcity/gomod v1.0.1
github.com/docker/distribution v2.8.1+incompatible
github.com/docker/libcompose v0.4.1-0.20181019154650-213509acef0f
github.com/google/go-github/v45 v45.2.0
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc
github.com/hashicorp/go-version v1.2.0
github.com/ory/dockertest/v3 v3.6.5
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0
Expand Down Expand Up @@ -84,6 +84,6 @@ require (

replace (
github.com/Nvveen/Gotty => github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd
github.com/aquasecurity/go-version => github.com/beornf/goversion v0.0.0-20230212045613-eac47a9c209d
github.com/docker/libcompose => github.com/beornf/libcompose v0.4.1-0.20210215180846-a59802c0f07c
github.com/hashicorp/go-version => github.com/beornf/go-version v1.1.1-0.20200317142312-136b0131ea06
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/beornf/go-version v1.1.1-0.20200317142312-136b0131ea06 h1:cfKucAEg3G/tffpQn0rMy+N5JqXa7kJIEczaOCDh+A8=
github.com/beornf/go-version v1.1.1-0.20200317142312-136b0131ea06/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/beornf/goversion v0.0.0-20230212045613-eac47a9c209d h1:BP1Y4UYwcLtyBognUrZRBqsY+/34Xs1eg/wqidQzpaM=
github.com/beornf/goversion v0.0.0-20230212045613-eac47a9c209d/go.mod h1:9Beu8XsUNNfzml7WBf3QmyPToP1wm1Gj/Vc5UJKqTzU=
github.com/beornf/libcompose v0.4.1-0.20210215180846-a59802c0f07c h1:tDYcjKncxyn3Cj0UDnDxjy8oH0RruaMQSxXE5s7suzI=
github.com/beornf/libcompose v0.4.1-0.20210215180846-a59802c0f07c/go.mod h1:9+ps1KKtVtRUdpVxJldssQItPf/S5t5bO0zh4A0Hy5g=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
Expand Down Expand Up @@ -670,6 +670,7 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down Expand Up @@ -1088,6 +1089,7 @@ github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/uudashr/gocognit v1.0.1/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
Expand Down
23 changes: 7 additions & 16 deletions pack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"strings"
"time"

"github.com/aquasecurity/go-version/pkg/version"
"github.com/bmatcuk/doublestar"
"github.com/cloudingcity/gomod"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/client"
"github.com/google/go-github/v45/github"
"github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache"
"github.com/hashicorp/go-version"
"golang.org/x/oauth2"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -259,40 +259,31 @@ func getVersion(meta *Metadata) error {

versions := []string{}
for _, tag := range tags {
var v *version.Version
v, err = version.NewVersion(tag)
var v version.Version
v, err = version.Parse(tag)
if err != nil || v.Prerelease() != meta.Variant {
continue
}
versions = append(versions, tag)
}

sort.Slice(versions, func(i, j int) bool {
v1, _ := version.NewVersion(versions[i])
v2, _ := version.NewVersion(versions[j])
v1, _ := version.Parse(versions[i])
v2, _ := version.Parse(versions[j])
if v1.Equal(v2) {
return versions[i] > versions[j]
}
return v1.GreaterThan(v2)
})

meta.Version = strings.TrimRight(meta.Version, ".x*")
if meta.Version == "" {
meta.Version = ">0"
}

constraints, err := version.NewConstraint(meta.Version)
constraints, err := version.NewConstraints(meta.Version)
if err != nil {
return err
}

for _, tag := range versions {
ver := strings.Split(tag, "-")[0]
if meta.Version < ver {
continue
}

v, _ := version.NewVersion(ver)
v, _ := version.Parse(ver)
if constraints.Check(v) {
meta.Version = tag
return nil
Expand Down
6 changes: 3 additions & 3 deletions pack/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"strings"

"github.com/hashicorp/go-version"
"github.com/aquasecurity/go-version/pkg/version"
)

type NodePack struct {
Expand Down Expand Up @@ -39,12 +39,12 @@ func (n *NodePack) Metadata() *Metadata {
return nil
}

constraints, err := version.NewConstraint("^8.12 || >=10.3")
constraints, err := version.NewConstraints("^8.12 || >=10.3")
if err != nil {
return err
}

v, _ := version.NewVersion(meta.Version)
v, _ := version.Parse(meta.Version)
if constraints.Check(v) {
tool.Install = []string{"ci"}
}
Expand Down

0 comments on commit ac70c65

Please sign in to comment.