Recognize newer docker versions without -ce/-ee suffix

Since docker 18.09, the ServerVersion field format changed: the `-ce`
or `-ee` suffix disappeared:

- docker 18.06: `18.06.1-ce`
- docker 18.09: `18.09.0`

This was not expected by the docker_validator version regexp, which
assumed newer docker versions ended with `-[a-z]{2}`.
This made the validator return an error, whereas we expect it to
return only a warning (by recognizing it as a newer but not yet
supported docker version).

This commit relax the version regexp to also recognize `18.09.0`.
The docker validator now returns a warning, as tested.
This commit is contained in:
Thomas Riccardi 2018-11-13 18:55:29 +01:00
parent 9199025b24
commit 068cdaa56c
2 changed files with 6 additions and 1 deletions

View File

@ -73,7 +73,7 @@ func (d *DockerValidator) validateDockerInfo(spec *DockerSpec, info types.Info)
if !matched { if !matched {
// If it's of the new Docker version scheme but didn't match above, it // If it's of the new Docker version scheme but didn't match above, it
// must be a newer version than the most recently validated one. // must be a newer version than the most recently validated one.
ver := `\d{2}\.\d+\.\d+-[a-z]{2}` ver := `\d{2}\.\d+\.\d+(?:-[a-z]{2})?`
r := regexp.MustCompile(ver) r := regexp.MustCompile(ver)
if r.MatchString(info.ServerVersion) { if r.MatchString(info.ServerVersion) {
d.Reporter.Report(dockerConfigPrefix+"VERSION", info.ServerVersion, good) d.Reporter.Report(dockerConfigPrefix+"VERSION", info.ServerVersion, good)

View File

@ -81,6 +81,11 @@ func TestValidateDockerInfo(t *testing.T) {
err: false, err: false,
warn: false, warn: false,
}, },
{
info: types.Info{Driver: "driver_2", ServerVersion: "18.09.0"},
err: false,
warn: true,
},
} { } {
warn, err := v.validateDockerInfo(spec, test.info) warn, err := v.validateDockerInfo(spec, test.info)
if !test.err { if !test.err {