Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
1d2fa5ac
Commit
1d2fa5ac
authored
5 years ago
by
Michael Schurter
Browse files
Options
Download
Email Patches
Plain Diff
vendor: update go-version to include NewSemver
parent
04b588dc
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
vendor/github.com/hashicorp/go-version/README.md
+1
-1
vendor/github.com/hashicorp/go-version/README.md
vendor/github.com/hashicorp/go-version/go.mod
+1
-0
vendor/github.com/hashicorp/go-version/go.mod
vendor/github.com/hashicorp/go-version/version.go
+40
-7
vendor/github.com/hashicorp/go-version/version.go
vendor/vendor.json
+1
-1
vendor/vendor.json
with
43 additions
and
9 deletions
+43
-9
vendor/github.com/hashicorp/go-version/README.md
+
1
-
1
View file @
1d2fa5ac
# Versioning Library for Go
[

](https://travis-ci.org
/hashicorp/go-version)
[

](https://circleci.com/gh
/hashicorp/go-version
/tree/master
)
go-version is a library for parsing versions and version constraints,
and verifying versions against a set of constraints. go-version
...
...
This diff is collapsed.
Click to expand it.
vendor/github.com/hashicorp/go-version/go.mod
0 → 100644
+
1
-
0
View file @
1d2fa5ac
module github.com/hashicorp/go-version
This diff is collapsed.
Click to expand it.
vendor/github.com/hashicorp/go-version/version.go
+
40
-
7
View file @
1d2fa5ac
...
...
@@ -10,14 +10,25 @@ import (
)
// The compiled regular expression used to test the validity of a version.
var
versionRegexp
*
regexp
.
Regexp
var
(
versionRegexp
*
regexp
.
Regexp
semverRegexp
*
regexp
.
Regexp
)
// The raw regular expression string used for testing the validity
// of a version.
const
VersionRegexpRaw
string
=
`v?([0-9]+(\.[0-9]+)*?)`
+
`(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-?([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?`
+
`(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?`
+
`?`
const
(
VersionRegexpRaw
string
=
`v?([0-9]+(\.[0-9]+)*?)`
+
`(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-?([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?`
+
`(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?`
+
`?`
// SemverRegexpRaw requires a separator between version and prerelease
SemverRegexpRaw
string
=
`v?([0-9]+(\.[0-9]+)*?)`
+
`(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?`
+
`(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?`
+
`?`
)
// Version represents a single version.
type
Version
struct
{
...
...
@@ -30,12 +41,24 @@ type Version struct {
func
init
()
{
versionRegexp
=
regexp
.
MustCompile
(
"^"
+
VersionRegexpRaw
+
"$"
)
semverRegexp
=
regexp
.
MustCompile
(
"^"
+
SemverRegexpRaw
+
"$"
)
}
// NewVersion parses the given version and returns a new
// Version.
func
NewVersion
(
v
string
)
(
*
Version
,
error
)
{
matches
:=
versionRegexp
.
FindStringSubmatch
(
v
)
return
newVersion
(
v
,
versionRegexp
)
}
// NewSemver parses the given version and returns a new
// Version that adheres strictly to SemVer specs
// https://semver.org/
func
NewSemver
(
v
string
)
(
*
Version
,
error
)
{
return
newVersion
(
v
,
semverRegexp
)
}
func
newVersion
(
v
string
,
pattern
*
regexp
.
Regexp
)
(
*
Version
,
error
)
{
matches
:=
pattern
.
FindStringSubmatch
(
v
)
if
matches
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Malformed version: %s"
,
v
)
}
...
...
@@ -89,7 +112,7 @@ func Must(v *Version, err error) *Version {
// or larger than the other version, respectively.
//
// If you want boolean results, use the LessThan, Equal,
//
or
GreaterThan methods.
// GreaterThan
, GreaterThanOrEqual or LessThanOrEqual
methods.
func
(
v
*
Version
)
Compare
(
other
*
Version
)
int
{
// A quick, efficient equality check
if
v
.
String
()
==
other
.
String
()
{
...
...
@@ -265,11 +288,21 @@ func (v *Version) GreaterThan(o *Version) bool {
return
v
.
Compare
(
o
)
>
0
}
// GreaterThanOrEqual tests if this version is greater than or equal to another version.
func
(
v
*
Version
)
GreaterThanOrEqual
(
o
*
Version
)
bool
{
return
v
.
Compare
(
o
)
>=
0
}
// LessThan tests if this version is less than another version.
func
(
v
*
Version
)
LessThan
(
o
*
Version
)
bool
{
return
v
.
Compare
(
o
)
<
0
}
// LessThanOrEqual tests if this version is less than or equal to another version.
func
(
v
*
Version
)
LessThanOrEqual
(
o
*
Version
)
bool
{
return
v
.
Compare
(
o
)
<=
0
}
// Metadata returns any metadata that was part of the version
// string.
//
...
...
This diff is collapsed.
Click to expand it.
vendor/vendor.json
+
1
-
1
View file @
1d2fa5ac
...
...
@@ -225,7 +225,7 @@
{
"path"
:
"github.com/hashicorp/go-sockaddr/template"
,
"checksumSHA1"
:
"PDp9DVLvf3KWxhs4G4DpIwauMSU="
,
"revision"
:
"6d291a969b86c4b633730bfc6b8b9d64c3aafed9"
,
"revisionTime"
:
"2018-03-20T11:50:54Z"
},
{
"path"
:
"github.com/hashicorp/go-syslog"
,
"checksumSHA1"
:
"eEqQGKsFOdSAwEprYgYnL7+J2e0="
,
"revision"
:
"8d1874e3e8d1862b74e0536851e218c4571066a5"
,
"revisionTime"
:
"2019-01-18T15:19:36Z"
,
"version"
:
"v1.0.0"
,
"versionExact"
:
"v1.0.0"
},
{
"path"
:
"github.com/hashicorp/go-uuid"
,
"checksumSHA1"
:
"5AxXPtBqAKyFGcttFzxT5hp/3Tk="
,
"revision"
:
"4f571afc59f3043a65f8fe6bf46d887b10a01d43"
,
"revisionTime"
:
"2018-11-28T13:14:45Z"
},
{
"path"
:
"github.com/hashicorp/go-version"
,
"checksumSHA1"
:
"
r0pj5dMHCghpaQZ3f1BRGoKiSWw="
,
"revision"
:
"b5a281d3160aa11950a6182bd9a9dc2cb1e02d50
"
,
"revisionTime"
:
"201
8-08-24T00:43:55
Z"
},
{
"path"
:
"github.com/hashicorp/go-version"
,
"checksumSHA1"
:
"
+wX9Wh8280cHZMckQlOit3UrwbA="
,
"revision"
:
"2046c9d0f0b03c779670f5186a2a4b2c85493a71
"
,
"revisionTime"
:
"201
9-10-09T19:36:37
Z"
},
{
"path"
:
"github.com/hashicorp/golang-lru"
,
"checksumSHA1"
:
"d9PxF1XQGLMJZRct2R8qVM/eYlE="
,
"revision"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
,
"revisionTime"
:
"2016-02-07T21:47:19Z"
},
{
"path"
:
"github.com/hashicorp/golang-lru/simplelru"
,
"checksumSHA1"
:
"2nOpYjx8Sn57bqlZq17yM4YJuM4="
,
"revision"
:
"a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
},
{
"path"
:
"github.com/hashicorp/hcl"
,
"checksumSHA1"
:
"vgGv8zuy7q8c5LBAFO1fnnQRRgE="
,
"revision"
:
"1804807358d86424faacbb42f50f0c04303cef11"
,
"revisionTime"
:
"2019-06-10T16:16:27Z"
},
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help