Skip to content

Commit

Permalink
Switch to 'github.com/blang/semver' as we already have this as a (ind…
Browse files Browse the repository at this point in the history
…irect) dependency.
  • Loading branch information
Sven Rebhan committed Nov 17, 2021
1 parent d013d33 commit 184d745
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"strings"
"time"

"github.com/coreos/go-semver/semver"
"github.com/blang/semver"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
Expand Down Expand Up @@ -81,7 +81,7 @@ type Config struct {
AggProcessors models.RunningProcessors

Deprecations map[string][]int64
version *semver.Version
version semver.Version
}

// NewConfig creates a new struct to hold the Telegraf config.
Expand Down Expand Up @@ -115,7 +115,7 @@ func NewConfig() *Config {
if version == "" || version == "unknown" {
version = "0.0.0-unknown"
}
c.version = semver.New(version)
c.version = semver.MustParse(version)

tomlCfg := &toml.Config{
NormFieldName: toml.DefaultConfig.NormFieldName,
Expand Down
17 changes: 8 additions & 9 deletions config/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"strings"

"github.com/coreos/go-semver/semver"
"github.com/blang/semver"
"github.com/fatih/color"

"github.com/influxdata/telegraf"
Expand Down Expand Up @@ -48,32 +48,31 @@ type deprecationInfo struct {
info telegraf.DeprecationInfo
}

func (di *deprecationInfo) determineEscalation(version *semver.Version) error {
func (di *deprecationInfo) determineEscalation(version semver.Version) error {
di.LogLevel = None
if di.info.Since == "" {
return nil
}

since, err := semver.NewVersion(di.info.Since)
since, err := semver.Parse(di.info.Since)
if err != nil {
return fmt.Errorf("cannot parse 'since' version %q: %v", di.info.Since, err)
}

var removal *semver.Version
var removal semver.Version
if di.info.RemovalIn != "" {
removal, err = semver.NewVersion(di.info.RemovalIn)
removal, err = semver.Parse(di.info.RemovalIn)
if err != nil {
return fmt.Errorf("cannot parse 'removal' version %q: %v", di.info.RemovalIn, err)
}
} else {
removal = &semver.Version{Major: since.Major}
removal.BumpMajor()
removal = semver.Version{Major: since.Major + 1}
di.info.RemovalIn = removal.String()
}

if !version.LessThan(*removal) {
if version.GTE(removal) {
di.LogLevel = Error
} else if !version.LessThan(*since) {
} else if version.GTE(since) {
di.LogLevel = Warn
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ following works:
- github.com/awslabs/kinesis-aggregation/go [Apache License 2.0](https://github.com/awslabs/kinesis-aggregation/blob/master/LICENSE.txt)
- github.com/benbjohnson/clock [MIT License](https://github.com/benbjohnson/clock/blob/master/LICENSE)
- github.com/beorn7/perks [MIT License](https://github.com/beorn7/perks/blob/master/LICENSE)
- github.com/blang/semver [MIT License](https://github.com/blang/semver/blob/master/LICENSE)
- github.com/bmatcuk/doublestar [MIT License](https://github.com/bmatcuk/doublestar/blob/master/LICENSE)
- github.com/caio/go-tdigest [MIT License](https://github.com/caio/go-tdigest/blob/master/LICENSE)
- github.com/cenkalti/backoff [MIT License](https://github.com/cenkalti/backoff/blob/master/LICENSE)
- github.com/cespare/xxhash [MIT License](https://github.com/cespare/xxhash/blob/master/LICENSE.txt)
- github.com/cisco-ie/nx-telemetry-proto [Apache License 2.0](https://github.com/cisco-ie/nx-telemetry-proto/blob/master/LICENSE)
- github.com/containerd/containerd [Apache License 2.0](https://github.com/containerd/containerd/blob/master/LICENSE)
- github.com/coreos/go-semver [Apache License 2.0](https://github.com/coreos/go-semver/blob/main/LICENSE)
- github.com/couchbase/go-couchbase [MIT License](https://github.com/couchbase/go-couchbase/blob/master/LICENSE)
- github.com/couchbase/gomemcached [MIT License](https://github.com/couchbase/gomemcached/blob/master/LICENSE)
- github.com/couchbase/goutils [Apache License 2.0](https://github.com/couchbase/goutils/blob/master/LICENSE.md)
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ require (
github.com/cisco-ie/nx-telemetry-proto v0.0.0-20190531143454-82441e232cf6
github.com/containerd/cgroups v1.0.1 // indirect
github.com/containerd/containerd v1.5.7 // indirect
github.com/coreos/go-semver v0.3.0
github.com/coreos/go-semver v0.3.0 // indirect
github.com/couchbase/go-couchbase v0.1.0
github.com/couchbase/gomemcached v0.1.3 // indirect
github.com/couchbase/goutils v0.1.0 // indirect
Expand Down Expand Up @@ -329,6 +329,8 @@ require (
sigs.k8s.io/yaml v1.2.0 // indirect
)

require github.com/blang/semver v3.5.1+incompatible

require github.com/libp2p/go-reuseport v0.1.0

require (
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmatcuk/doublestar/v3 v3.0.0 h1:TQtVPlDnAYwcrVNB2JiGuMc++H5qzWZd9PhkNo5WyHI=
github.com/bmatcuk/doublestar/v3 v3.0.0/go.mod h1:6PcTVMw80pCY1RVuoqu3V++99uQB3vsSYKPTd8AWA0k=
Expand Down

0 comments on commit 184d745

Please sign in to comment.