Support expanded mounts in Compose loader
Add a test for loading expanded mount format. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
@@ -837,13 +837,13 @@ func TestFullExample(t *testing.T) {
|
||||
},
|
||||
},
|
||||
User: "someone",
|
||||
Volumes: []string{
|
||||
"/var/lib/mysql",
|
||||
"/opt/data:/var/lib/mysql",
|
||||
fmt.Sprintf("%s:/code", workingDir),
|
||||
fmt.Sprintf("%s/static:/var/www/html", workingDir),
|
||||
fmt.Sprintf("%s/configs:/etc/configs/:ro", homeDir),
|
||||
"datavolume:/var/lib/mysql",
|
||||
Volumes: []types.ServiceVolumeConfig{
|
||||
{Target: "/var/lib/mysql", Type: "volume"},
|
||||
{Source: "/opt/data", Target: "/var/lib/mysql", Type: "bind"},
|
||||
{Source: workingDir, Target: "/code", Type: "bind"},
|
||||
{Source: workingDir + "/static", Target: "/var/www/html", Type: "bind"},
|
||||
{Source: homeDir + "/configs", Target: "/etc/configs/", Type: "bind", ReadOnly: true},
|
||||
{Source: "datavolume", Target: "/var/lib/mysql", Type: "volume"},
|
||||
},
|
||||
WorkingDir: "/code",
|
||||
}
|
||||
@@ -1041,3 +1041,31 @@ services:
|
||||
assert.Equal(t, 1, len(config.Services))
|
||||
assert.Equal(t, expected, config.Services[0].Ports)
|
||||
}
|
||||
|
||||
func TestLoadExpandedMountFormat(t *testing.T) {
|
||||
config, err := loadYAML(`
|
||||
version: "3.1"
|
||||
services:
|
||||
web:
|
||||
image: busybox
|
||||
volumes:
|
||||
- type: volume
|
||||
source: foo
|
||||
target: /target
|
||||
read_only: true
|
||||
volumes:
|
||||
foo: {}
|
||||
`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
expected := types.ServiceVolumeConfig{
|
||||
Type: "volume",
|
||||
Source: "foo",
|
||||
Target: "/target",
|
||||
ReadOnly: true,
|
||||
}
|
||||
|
||||
assert.Equal(t, 1, len(config.Services))
|
||||
assert.Equal(t, 1, len(config.Services[0].Volumes))
|
||||
assert.Equal(t, expected, config.Services[0].Volumes[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user