mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
chore(backend): use Masterminds/semver instead of blang/semver
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/prymitive/karma/internal/config"
|
||||
@@ -918,8 +918,11 @@ func testAlert(version string, t *testing.T, expectedAlert, gotAlert models.Aler
|
||||
version, expectedAM.Name, expectedAM.Source, gotAM.Source, gotAlert.Receiver, expectedAlert.Labels)
|
||||
}
|
||||
// multiple silences only work for >=0.6.1
|
||||
versionRange := semver.MustParseRange(">=0.6.1")
|
||||
if versionRange(semver.MustParse(version)) {
|
||||
versionRange, err := semver.NewConstraint(">=0.6.1")
|
||||
if err != nil {
|
||||
t.Errorf("[%s] Cannot create semver Constrain: %s", version, err)
|
||||
}
|
||||
if versionRange.Check(semver.MustParse(version)) {
|
||||
if len(gotAM.Silences) != len(expectedAM.Silences) {
|
||||
t.Errorf("[%s] Expected alertmanager '%s' to have %d silences but got %d on alert receiver='%s' labels=%v",
|
||||
version, expectedAM.Name, len(expectedAM.Silences), len(gotAM.Silences), gotAlert.Receiver, expectedAlert.Labels)
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.12
|
||||
|
||||
require (
|
||||
github.com/DeanThompson/ginpprof v0.0.0-20190408063150-3be636683586
|
||||
github.com/blang/semver v1.1.1-0.20190414182527-1a9109f8c4a1
|
||||
github.com/Masterminds/semver v1.4.2
|
||||
github.com/certifi/gocertifi v0.0.0-20190905060710-a5e0173ced67 // indirect
|
||||
github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1-0.20180223160309-38087fe4dafb
|
||||
|
||||
@@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/DeanThompson/ginpprof v0.0.0-20190408063150-3be636683586 h1:vDSj8WQZoe+dhK9JVwkSEBwtmcJw5rJ7l1L0Yik8Ku0=
|
||||
github.com/DeanThompson/ginpprof v0.0.0-20190408063150-3be636683586/go.mod h1:kMi/fSDAgvjo9TYfYwYeQ2vkyj+VTR/tB6u/Tjh39t0=
|
||||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/OpenPeeDeeP/depguard v1.0.0 h1:k9QF73nrHT3nPLz3lu6G5s+3Hi8Je36ODr1F5gjAXXM=
|
||||
github.com/OpenPeeDeeP/depguard v1.0.0/go.mod h1:7/4sitnI9YlQgTLLk734QlzXT8DuHVnAyztLplQjk+o=
|
||||
@@ -26,8 +28,6 @@ github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
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/blang/semver v1.1.1-0.20190414182527-1a9109f8c4a1 h1:Quy+QGP2Ia3Gv4c33NAFS/K9erlqriDt8KD9ZFuyfCo=
|
||||
github.com/blang/semver v1.1.1-0.20190414182527-1a9109f8c4a1/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/certifi/gocertifi v0.0.0-20190905060710-a5e0173ced67 h1:8k9FLYBLKT+9v2HQJ/a95ZemmTx+/ltJcAiRhVushG8=
|
||||
github.com/certifi/gocertifi v0.0.0-20190905060710-a5e0173ced67/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -50,8 +50,11 @@ func (s StatusMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (s StatusMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.15.0 <0.16.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.15.0, <0.16.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
@@ -28,8 +28,11 @@ func (m AlertMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m AlertMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.17.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.17.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -27,8 +27,11 @@ func (m SilenceMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m SilenceMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.17.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.17.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -27,8 +27,11 @@ func (s StatusMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (s StatusMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.17.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.17.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -65,8 +65,11 @@ func (m AlertMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m AlertMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.4.0 <0.5.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.4.0, <0.5.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -63,8 +63,11 @@ func (m SilenceMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m SilenceMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.4.0 <0.5.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.4.0, <0.5.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -50,8 +50,11 @@ func (s StatusMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (s StatusMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.4.0 <0.15.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.4.0, <0.15.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -64,8 +64,11 @@ func (m AlertMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m AlertMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.5.0 <=0.6.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.5.0, <=0.6.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -53,8 +53,11 @@ func (m SilenceMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m SilenceMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.5.0 <0.16.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.5.0, <0.16.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -66,8 +66,11 @@ func (m AlertMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m AlertMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange("=0.6.1")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint("=0.6.1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/prymitive/karma/internal/mapper"
|
||||
"github.com/prymitive/karma/internal/models"
|
||||
"github.com/prymitive/karma/internal/uri"
|
||||
@@ -70,8 +70,11 @@ func (m AlertMapper) QueryArgs() string {
|
||||
|
||||
// IsSupported returns true if given version string is supported
|
||||
func (m AlertMapper) IsSupported(version string) bool {
|
||||
versionRange := semver.MustParseRange(">=0.6.2 <0.16.0")
|
||||
return versionRange(semver.MustParse(version))
|
||||
versionRange, err := semver.NewConstraint(">=0.6.2, <0.16.0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return versionRange.Check(semver.MustParse(version))
|
||||
}
|
||||
|
||||
// IsOpenAPI returns true is remote Alertmanager uses OpenAPI
|
||||
|
||||
Reference in New Issue
Block a user