diff --git a/vendor/github.com/hashicorp/go-version/constraint.go b/vendor/github.com/hashicorp/go-version/constraint.go index 8c73df060..d05575961 100644 --- a/vendor/github.com/hashicorp/go-version/constraint.go +++ b/vendor/github.com/hashicorp/go-version/constraint.go @@ -2,6 +2,7 @@ package version import ( "fmt" + "reflect" "regexp" "strings" ) @@ -113,6 +114,26 @@ func parseSingle(v string) (*Constraint, error) { }, nil } +func prereleaseCheck(v, c *Version) bool { + switch vPre, cPre := v.Prerelease() != "", c.Prerelease() != ""; { + case cPre && vPre: + // A constraint with a pre-release can only match a pre-release version + // with the same base segments. + return reflect.DeepEqual(c.Segments64(), v.Segments64()) + + case !cPre && vPre: + // A constraint without a pre-release can only match a version without a + // pre-release. + return false + + case cPre && !vPre: + // OK, except with the pessimistic operator + case !cPre && !vPre: + // OK + } + return true +} + //------------------------------------------------------------------- // Constraint functions //------------------------------------------------------------------- @@ -126,22 +147,27 @@ func constraintNotEqual(v, c *Version) bool { } func constraintGreaterThan(v, c *Version) bool { - return v.Compare(c) == 1 + return prereleaseCheck(v, c) && v.Compare(c) == 1 } func constraintLessThan(v, c *Version) bool { - return v.Compare(c) == -1 + return prereleaseCheck(v, c) && v.Compare(c) == -1 } func constraintGreaterThanEqual(v, c *Version) bool { - return v.Compare(c) >= 0 + return prereleaseCheck(v, c) && v.Compare(c) >= 0 } func constraintLessThanEqual(v, c *Version) bool { - return v.Compare(c) <= 0 + return prereleaseCheck(v, c) && v.Compare(c) <= 0 } func constraintPessimistic(v, c *Version) bool { + // Using a pessimistic constraint with a pre-release, restricts versions to pre-releases + if !prereleaseCheck(v, c) || (c.Prerelease() != "" && v.Prerelease() == "") { + return false + } + // If the version being checked is naturally less than the constraint, then there // is no way for the version to be valid against the constraint if v.LessThan(c) { diff --git a/vendor/vendor.json b/vendor/vendor.json index a5b73e582..c73ec708d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1815,10 +1815,12 @@ "revision": "36289988d83ca270bc07c234c36f364b0dd9c9a7" }, { - "checksumSHA1": "9w1ZtxhdB/J0qqNPJQNNI/ZTwwE=", + "checksumSHA1": "4+PK0yd1prnC11PETgrXPzHyct4=", "path": "github.com/hashicorp/go-version", - "revision": "4fe82ae3040f80a03d04d2cccb5606a626b8e1ee", - "revisionTime": "2017-11-29T15:08:20Z" + "revision": "23480c0665776210b5fbbac6eaaee40e3e6a96b7", + "revisionTime": "2018-03-22T23:02:33Z", + "version": "master", + "versionExact": "master" }, { "checksumSHA1": "o3XZZdOnSnwQSpYw215QV75ZDeI=",