Add "host-gateway" to tests for extra_hosts / --add-host

67ebcd6dcf added an exception for
the "host-gateway" magic value to the validation rules, but didn't
add thise value to any of the tests.

This patch adds the magic value to tests, to verify the validation
is skipped for this magic value.

Note that validation on the client side is "optional" and mostly
done to provide a more user-friendly error message for regular
values (IP-addresses).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2020-04-15 09:13:11 +02:00
parent 42f5b8a3e1
commit f88ae74135
5 changed files with 17 additions and 3 deletions

View File

@ -140,9 +140,11 @@ services:
# extra_hosts:
# somehost: "162.242.195.82"
# otherhost: "50.31.209.229"
# host.docker.internal: "host-gateway"
extra_hosts:
- "somehost:162.242.195.82"
- "otherhost:50.31.209.229"
- "host.docker.internal:host-gateway"
hostname: foo

View File

@ -144,6 +144,7 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
ExtraHosts: []string{
"somehost:162.242.195.82",
"otherhost:50.31.209.229",
"host.docker.internal:host-gateway",
},
Extras: map[string]interface{}{
"x-bar": "baz",
@ -626,6 +627,7 @@ services:
extra_hosts:
- somehost:162.242.195.82
- otherhost:50.31.209.229
- host.docker.internal:host-gateway
hostname: foo
healthcheck:
test:
@ -1135,7 +1137,8 @@ func fullExampleJSON(workingDir string) string {
],
"extra_hosts": [
"somehost:162.242.195.82",
"otherhost:50.31.209.229"
"otherhost:50.31.209.229",
"host.docker.internal:host-gateway"
],
"hostname": "foo",
"healthcheck": {

View File

@ -1276,11 +1276,13 @@ services:
extra_hosts:
"zulu": "162.242.195.82"
"alpha": "50.31.209.229"
"host.docker.internal": "host-gateway"
`)
assert.NilError(t, err)
expected := types.HostsList{
"alpha:50.31.209.229",
"host.docker.internal:host-gateway",
"zulu:162.242.195.82",
}
@ -1298,6 +1300,7 @@ services:
- "zulu:162.242.195.82"
- "alpha:50.31.209.229"
- "zulu:ff02::1"
- "host.docker.internal:host-gateway"
`)
assert.NilError(t, err)
@ -1305,6 +1308,7 @@ services:
"zulu:162.242.195.82",
"alpha:50.31.209.229",
"zulu:ff02::1",
"host.docker.internal:host-gateway",
}
assert.Assert(t, is.Len(config.Services, 1))