vendor: bump github.com/hashicorp/go-version from 1.3.0 to 1.4.0 (#1210)

This commit is contained in:
dependabot[bot] 2022-01-28 02:41:12 +00:00 коммит произвёл GitHub
Родитель 4b3f096145
Коммит a47c7c45a3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 110 добавлений и 19 удалений

2
go.mod
Просмотреть файл

@ -17,7 +17,7 @@ require (
github.com/google/go-cmp v0.5.6 github.com/google/go-cmp v0.5.6
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-version v1.3.0 github.com/hashicorp/go-version v1.4.0
github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee // indirect github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee // indirect
github.com/microsoft/ApplicationInsights-Go v0.4.4 github.com/microsoft/ApplicationInsights-Go v0.4.4
github.com/nxadm/tail v1.4.8 github.com/nxadm/tail v1.4.8

4
go.sum
Просмотреть файл

@ -510,8 +510,8 @@ 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-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.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-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4=
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= 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.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=

7
vendor/github.com/hashicorp/go-version/CHANGELOG.md сгенерированный поставляемый
Просмотреть файл

@ -1,3 +1,10 @@
# 1.4.0 (January 5, 2021)
FEATURES:
- Introduce `MustConstraints()` ([#87](https://github.com/hashicorp/go-version/pull/87))
- `Constraints`: Introduce `Equals()` and `sort.Interface` methods ([#88](https://github.com/hashicorp/go-version/pull/88))
# 1.3.0 (March 31, 2021) # 1.3.0 (March 31, 2021)
Please note that CHANGELOG.md does not exist in the source code prior to this release. Please note that CHANGELOG.md does not exist in the source code prior to this release.

108
vendor/github.com/hashicorp/go-version/constraint.go сгенерированный поставляемый
Просмотреть файл

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"regexp" "regexp"
"sort"
"strings" "strings"
) )
@ -11,30 +12,40 @@ import (
// ">= 1.0". // ">= 1.0".
type Constraint struct { type Constraint struct {
f constraintFunc f constraintFunc
op operator
check *Version check *Version
original string original string
} }
func (c *Constraint) Equals(con *Constraint) bool {
return c.op == con.op && c.check.Equal(con.check)
}
// Constraints is a slice of constraints. We make a custom type so that // Constraints is a slice of constraints. We make a custom type so that
// we can add methods to it. // we can add methods to it.
type Constraints []*Constraint type Constraints []*Constraint
type constraintFunc func(v, c *Version) bool type constraintFunc func(v, c *Version) bool
var constraintOperators map[string]constraintFunc var constraintOperators map[string]constraintOperation
type constraintOperation struct {
op operator
f constraintFunc
}
var constraintRegexp *regexp.Regexp var constraintRegexp *regexp.Regexp
func init() { func init() {
constraintOperators = map[string]constraintFunc{ constraintOperators = map[string]constraintOperation{
"": constraintEqual, "": {op: equal, f: constraintEqual},
"=": constraintEqual, "=": {op: equal, f: constraintEqual},
"!=": constraintNotEqual, "!=": {op: notEqual, f: constraintNotEqual},
">": constraintGreaterThan, ">": {op: greaterThan, f: constraintGreaterThan},
"<": constraintLessThan, "<": {op: lessThan, f: constraintLessThan},
">=": constraintGreaterThanEqual, ">=": {op: greaterThanEqual, f: constraintGreaterThanEqual},
"<=": constraintLessThanEqual, "<=": {op: lessThanEqual, f: constraintLessThanEqual},
"~>": constraintPessimistic, "~>": {op: pessimistic, f: constraintPessimistic},
} }
ops := make([]string, 0, len(constraintOperators)) ops := make([]string, 0, len(constraintOperators))
@ -66,6 +77,16 @@ func NewConstraint(v string) (Constraints, error) {
return Constraints(result), nil return Constraints(result), nil
} }
// MustConstraints is a helper that wraps a call to a function
// returning (Constraints, error) and panics if error is non-nil.
func MustConstraints(c Constraints, err error) Constraints {
if err != nil {
panic(err)
}
return c
}
// Check tests if a version satisfies all the constraints. // Check tests if a version satisfies all the constraints.
func (cs Constraints) Check(v *Version) bool { func (cs Constraints) Check(v *Version) bool {
for _, c := range cs { for _, c := range cs {
@ -77,6 +98,56 @@ func (cs Constraints) Check(v *Version) bool {
return true return true
} }
// Equals compares Constraints with other Constraints
// for equality. This may not represent logical equivalence
// of compared constraints.
// e.g. even though '>0.1,>0.2' is logically equivalent
// to '>0.2' it is *NOT* treated as equal.
//
// Missing operator is treated as equal to '=', whitespaces
// are ignored and constraints are sorted before comaparison.
func (cs Constraints) Equals(c Constraints) bool {
if len(cs) != len(c) {
return false
}
// make copies to retain order of the original slices
left := make(Constraints, len(cs))
copy(left, cs)
sort.Stable(left)
right := make(Constraints, len(c))
copy(right, c)
sort.Stable(right)
// compare sorted slices
for i, con := range left {
if !con.Equals(right[i]) {
return false
}
}
return true
}
func (cs Constraints) Len() int {
return len(cs)
}
func (cs Constraints) Less(i, j int) bool {
if cs[i].op < cs[j].op {
return true
}
if cs[i].op > cs[j].op {
return false
}
return cs[i].check.LessThan(cs[j].check)
}
func (cs Constraints) Swap(i, j int) {
cs[i], cs[j] = cs[j], cs[i]
}
// Returns the string format of the constraints // Returns the string format of the constraints
func (cs Constraints) String() string { func (cs Constraints) String() string {
csStr := make([]string, len(cs)) csStr := make([]string, len(cs))
@ -107,8 +178,11 @@ func parseSingle(v string) (*Constraint, error) {
return nil, err return nil, err
} }
cop := constraintOperators[matches[1]]
return &Constraint{ return &Constraint{
f: constraintOperators[matches[1]], f: cop.f,
op: cop.op,
check: check, check: check,
original: v, original: v,
}, nil }, nil
@ -138,6 +212,18 @@ func prereleaseCheck(v, c *Version) bool {
// Constraint functions // Constraint functions
//------------------------------------------------------------------- //-------------------------------------------------------------------
type operator rune
const (
equal operator = '='
notEqual operator = '≠'
greaterThan operator = '>'
lessThan operator = '<'
greaterThanEqual operator = '≥'
lessThanEqual operator = '≤'
pessimistic operator = '~'
)
func constraintEqual(v, c *Version) bool { func constraintEqual(v, c *Version) bool {
return v.Equal(c) return v.Equal(c)
} }

6
vendor/github.com/hashicorp/go-version/version.go сгенерированный поставляемый
Просмотреть файл

@ -64,7 +64,6 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
} }
segmentsStr := strings.Split(matches[1], ".") segmentsStr := strings.Split(matches[1], ".")
segments := make([]int64, len(segmentsStr)) segments := make([]int64, len(segmentsStr))
si := 0
for i, str := range segmentsStr { for i, str := range segmentsStr {
val, err := strconv.ParseInt(str, 10, 64) val, err := strconv.ParseInt(str, 10, 64)
if err != nil { if err != nil {
@ -72,8 +71,7 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
"Error parsing version: %s", err) "Error parsing version: %s", err)
} }
segments[i] = int64(val) segments[i] = val
si++
} }
// Even though we could support more than three segments, if we // Even though we could support more than three segments, if we
@ -92,7 +90,7 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
metadata: matches[10], metadata: matches[10],
pre: pre, pre: pre,
segments: segments, segments: segments,
si: si, si: len(segmentsStr),
original: v, original: v,
}, nil }, nil
} }

2
vendor/modules.txt поставляемый
Просмотреть файл

@ -135,7 +135,7 @@ github.com/googleapis/gnostic/openapiv2
# github.com/gorilla/mux v1.8.0 # github.com/gorilla/mux v1.8.0
## explicit; go 1.12 ## explicit; go 1.12
github.com/gorilla/mux github.com/gorilla/mux
# github.com/hashicorp/go-version v1.3.0 # github.com/hashicorp/go-version v1.4.0
## explicit ## explicit
github.com/hashicorp/go-version github.com/hashicorp/go-version
# github.com/hashicorp/hcl v1.0.0 # github.com/hashicorp/hcl v1.0.0