Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #245 from vania-pooh/master
Browse files Browse the repository at this point in the history
Removed MPL-based go-version library (fixes #244)
  • Loading branch information
vania-pooh authored Oct 8, 2019
2 parents 2a857c5 + 070e61e commit d2009cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/aerokube/cm

require (
github.com/Masterminds/semver/v3 v3.0.1
github.com/Microsoft/hcsshim v0.8.6 // indirect
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e
github.com/aerokube/selenoid v0.0.0-20171028174040-28a032c1afe5
Expand All @@ -17,7 +18,6 @@ require (
github.com/fatih/color v1.5.0
github.com/google/go-github v0.0.0-20170519031903-ebfec748347a
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
github.com/hashicorp/go-version v0.0.0-20171129150820-4fe82ae3040f
github.com/heroku/docker-registry-client v0.0.0-20171019183014-fd2fe8034968
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.0.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.0.1 h1:2kKm5lb7dKVrt5TYUiAavE6oFc1cFT0057UVGT+JqLk=
github.com/Masterminds/semver/v3 v3.0.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc=
github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA=
Expand Down Expand Up @@ -54,8 +56,6 @@ github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOF
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/hashicorp/go-version v0.0.0-20171129150820-4fe82ae3040f h1:QnRipjW3Mm+sgD+vyO87cb+1RLzoM0mGVTYClil7mQg=
github.com/hashicorp/go-version v0.0.0-20171129150820-4fe82ae3040f/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/heroku/docker-registry-client v0.0.0-20171019183014-fd2fe8034968 h1:FKcwev/l8kr6OBcgYHWxYSlVTHRRZbYIGhn0uddhmyM=
github.com/heroku/docker-registry-client v0.0.0-20171019183014-fd2fe8034968/go.mod h1:ceV82AfTGFCOL/b0cdpP54uKVSL1Gef0TBSTGFDuqyY=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
Expand Down
21 changes: 11 additions & 10 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"time"

"github.com/Masterminds/semver/v3"
"github.com/aerokube/selenoid/config"
authconfig "github.com/docker/cli/cli/config"
"github.com/docker/docker/api/types"
Expand All @@ -25,7 +26,6 @@ import (
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
ver "github.com/hashicorp/go-version"
"github.com/heroku/docker-registry-client/registry"
"github.com/mattn/go-colorable"

Expand Down Expand Up @@ -393,19 +393,20 @@ func (c *DockerConfigurator) createConfig() SelenoidConfig {
return browsers
}

func parseRequestedBrowsers(logger *Logger, requestedBrowsers string) map[string][]ver.Constraints {
ret := make(map[string][]ver.Constraints)
func parseRequestedBrowsers(logger *Logger, requestedBrowsers string) map[string][]*semver.Constraints {
ret := make(map[string][]*semver.Constraints)
if requestedBrowsers != "" {
for _, section := range strings.Split(requestedBrowsers, semicolon) {
pieces := strings.Split(section, colon)
if len(pieces) >= 1 {
browserName := strings.TrimSpace(pieces[0])
if _, ok := ret[browserName]; !ok {
ret[browserName] = []ver.Constraints{}
ret[browserName] = []*semver.Constraints{}
}
if len(pieces) == 2 {
versionConstraintString := strings.TrimSpace(pieces[1])
versionConstraint, err := ver.NewConstraint(versionConstraintString)

versionConstraint, err := semver.NewConstraint(versionConstraintString)
if err != nil {
logger.Errorf(`Invalid version constraint %s: %v - ignoring browser "%s"...`, versionConstraintString, err, browserName)
continue
Expand All @@ -418,7 +419,7 @@ func parseRequestedBrowsers(logger *Logger, requestedBrowsers string) map[string
return ret
}

func (c *DockerConfigurator) getBrowsersToIterate(requestedBrowsers map[string][]ver.Constraints) map[string]string {
func (c *DockerConfigurator) getBrowsersToIterate(requestedBrowsers map[string][]*semver.Constraints) map[string]string {
defaultBrowsers := map[string]string{
"firefox": "selenoid/firefox",
"chrome": "selenoid/chrome",
Expand Down Expand Up @@ -470,11 +471,11 @@ func filterOutLatest(tags []string) []string {
return ret
}

func (c *DockerConfigurator) filterTags(tags []string, versionConstraints []ver.Constraints) []string {
func (c *DockerConfigurator) filterTags(tags []string, versionConstraints []*semver.Constraints) []string {
if len(versionConstraints) > 0 {
var ret []string
for _, tag := range tags {
version, err := ver.NewVersion(tag)
version, err := semver.NewVersion(tag)
if err != nil {
c.Errorf("Skipping tag %s as it does not follow semantic versioning: %v", tag, err)
continue
Expand Down Expand Up @@ -750,8 +751,8 @@ func isVersion(version string, condition string, notSemanticVersionCallback func
if version == Latest {
return true
}
constraint, _ := ver.NewConstraint(condition)
v, err := ver.NewVersion(version)
constraint, _ := semver.NewConstraint(condition)
v, err := semver.NewVersion(version)
if err != nil {
notSemanticVersionCallback(version)
return false
Expand Down

0 comments on commit d2009cd

Please sign in to comment.