Skip to content

Commit

Permalink
[Maint] semver pkg change
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed committed Mar 5, 2024
1 parent 1fe5f85 commit 9e4687d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func bomb(err error) {
if err == nil {
return
}
panic(fmt.Sprintf("💥 %s\n", report.Colorize(err.Error(), report.ColorRed)))
panic(fmt.Errorf("💥 %s\n", report.Colorize(err.Error(), report.ColorRed)))
}

func initPopeyeFlags() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/derailed/popeye
go 1.21.1

require (
github.com/Masterminds/semver v1.5.0
github.com/aws/aws-sdk-go v1.35.21
github.com/blang/semver/v4 v4.0.0
github.com/fvbommel/sortorder v1.0.1
github.com/hashicorp/go-memdb v1.3.4
github.com/prometheus/client_golang v1.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/aws/aws-sdk-go v1.35.21 h1:6cMeHzcca+0uweOpUonDYv4DsPp9Qa9PTMYxH+VqDkY=
github.com/aws/aws-sdk-go v1.35.21/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
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/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
2 changes: 1 addition & 1 deletion internal/cache/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cache
import (
"errors"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
)

// ClusterKey tracks Cluster resource references
Expand Down
8 changes: 4 additions & 4 deletions internal/cache/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cache_test
import (
"testing"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
"github.com/derailed/popeye/internal/cache"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
Expand All @@ -17,11 +17,11 @@ func init() {
}

func TestCluster(t *testing.T) {
v, err := semver.NewVersion("1.9")
v, err := semver.ParseTolerant("1.9")
assert.NoError(t, err)

c := cache.NewCluster(v)
c := cache.NewCluster(&v)
v1, err := c.ListVersion()
assert.NoError(t, err)
assert.Equal(t, v, v1)
assert.Equal(t, &v, v1)
}
2 changes: 1 addition & 1 deletion internal/dag/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package dag
import (
"context"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
)

// ListVersion return server api version.
Expand Down
16 changes: 8 additions & 8 deletions internal/dag/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ package dag

import (
"errors"
"fmt"
"testing"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
)

func TestParseVers(t *testing.T) {
v, _ := semver.NewVersion("1.28")
v, _ := semver.ParseTolerant("1.28")

uu := map[string]struct {
info version.Info
err error
ver *semver.Version
ver semver.Version
}{
"empty": {
err: fmt.Errorf(`semver parse failed for "." (""|""): %w`, errors.New("Invalid Semantic Version")),
err: errors.New(`semver parse failed for "." (""|""): strconv.ParseUint: parsing "": invalid syntax`),
},
"happy": {
info: version.Info{Major: "1", Minor: "28"},
Expand All @@ -39,9 +38,10 @@ func TestParseVers(t *testing.T) {
u := uu[k]
t.Run(k, func(t *testing.T) {
v, err := ParseVersion(&u.info)
assert.Equal(t, u.err, err)
if err == nil {
assert.Equal(t, u.ver, v)
if err != nil {
assert.Equal(t, u.err.Error(), err.Error())
} else {
assert.Equal(t, &u.ver, v)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions internal/dag/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"strings"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
"github.com/derailed/popeye/internal"
"github.com/derailed/popeye/types"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -21,12 +21,12 @@ func ParseVersion(info *version.Info) (*semver.Version, error) {
return nil, fmt.Errorf("no cluster version available")
}
v := strings.TrimSuffix(info.Major+"."+info.Minor, "+")
rev, err := semver.NewVersion(v)
rev, err := semver.ParseTolerant(v)
if err != nil {
err = fmt.Errorf("semver parse failed for %q (%q|%q): %w", v, info.Major, info.Minor, err)
}

return rev, err
return &rev, err
}

func mustExtractFactory(ctx context.Context) types.Factory {
Expand Down
4 changes: 2 additions & 2 deletions internal/lint/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lint
import (
"context"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
"github.com/derailed/popeye/internal"
"github.com/derailed/popeye/internal/issues"
)
Expand Down Expand Up @@ -50,7 +50,7 @@ func (c *Cluster) checkVersion(ctx context.Context) error {
}

ctx = internal.WithSpec(ctx, specFor("Version", nil))
if rev.Major() != tolerableMajor || rev.Minor() < tolerableMinor {
if rev.Major != tolerableMajor || rev.Minor < tolerableMinor {
c.AddCode(ctx, 405)
} else {
c.AddCode(ctx, 406)
Expand Down
2 changes: 1 addition & 1 deletion internal/lint/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package lint
import (
"testing"

"github.com/Masterminds/semver"
"github.com/blang/semver/v4"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/version"

Expand Down

0 comments on commit 9e4687d

Please sign in to comment.