From 6c6200a3505efb936195082787cdaae42b7c9c17 Mon Sep 17 00:00:00 2001 From: Sven Rebhan Date: Wed, 17 Nov 2021 14:51:53 +0100 Subject: [PATCH] Switch to 'github.com/blang/semver' as we already have this as a (indirect) dependency. --- config/config.go | 6 +++--- config/deprecation.go | 17 ++++++++--------- docs/LICENSE_OF_DEPENDENCIES.md | 2 +- go.mod | 4 +++- go.sum | 1 + 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/config/config.go b/config/config.go index 8cb438e7b1d75..2328e80c855d0 100644 --- a/config/config.go +++ b/config/config.go @@ -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" @@ -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. @@ -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, diff --git a/config/deprecation.go b/config/deprecation.go index 51e4a63a9f114..8f99b5d034cf1 100644 --- a/config/deprecation.go +++ b/config/deprecation.go @@ -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" @@ -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 diff --git a/docs/LICENSE_OF_DEPENDENCIES.md b/docs/LICENSE_OF_DEPENDENCIES.md index bde02b8b3ab93..c06f97e6629e3 100644 --- a/docs/LICENSE_OF_DEPENDENCIES.md +++ b/docs/LICENSE_OF_DEPENDENCIES.md @@ -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) diff --git a/go.mod b/go.mod index d90d5f69269a8..863decb706f78 100644 --- a/go.mod +++ b/go.mod @@ -79,7 +79,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 @@ -332,6 +332,8 @@ require ( sigs.k8s.io/yaml v1.2.0 // indirect ) +require github.com/blang/semver v3.5.1+incompatible + require ( github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.2.0 // indirect github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.4.0 // indirect diff --git a/go.sum b/go.sum index 2799ef3c6fce6..f03bef813095d 100644 --- a/go.sum +++ b/go.sum @@ -424,6 +424,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=