mirror of
https://github.com/docker/compose.git
synced 2025-07-01 02:44:25 +02:00
ignore mount options which don't match type
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
74773b9062
commit
6ec682cade
@ -774,18 +774,50 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bind, vol, tmpfs := buildMountOptions(volume)
|
||||||
|
|
||||||
return mount.Mount{
|
return mount.Mount{
|
||||||
Type: mount.Type(volume.Type),
|
Type: mount.Type(volume.Type),
|
||||||
Source: source,
|
Source: source,
|
||||||
Target: volume.Target,
|
Target: volume.Target,
|
||||||
ReadOnly: volume.ReadOnly,
|
ReadOnly: volume.ReadOnly,
|
||||||
Consistency: mount.Consistency(volume.Consistency),
|
Consistency: mount.Consistency(volume.Consistency),
|
||||||
BindOptions: buildBindOption(volume.Bind),
|
BindOptions: bind,
|
||||||
VolumeOptions: buildVolumeOptions(volume.Volume),
|
VolumeOptions: vol,
|
||||||
TmpfsOptions: buildTmpfsOptions(volume.Tmpfs),
|
TmpfsOptions: tmpfs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildMountOptions(volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions) {
|
||||||
|
switch volume.Type {
|
||||||
|
case "bind":
|
||||||
|
if volume.Volume != nil {
|
||||||
|
logrus.Warnf("mount of type `bind` should not define `volume` option")
|
||||||
|
}
|
||||||
|
if volume.Tmpfs != nil {
|
||||||
|
logrus.Warnf("mount of type `tmpfs` should not define `tmpfs` option")
|
||||||
|
}
|
||||||
|
return buildBindOption(volume.Bind), nil, nil
|
||||||
|
case "volume":
|
||||||
|
if volume.Bind != nil {
|
||||||
|
logrus.Warnf("mount of type `volume` should not define `bind` option")
|
||||||
|
}
|
||||||
|
if volume.Tmpfs != nil {
|
||||||
|
logrus.Warnf("mount of type `volume` should not define `tmpfs` option")
|
||||||
|
}
|
||||||
|
return nil, buildVolumeOptions(volume.Volume), nil
|
||||||
|
case "tmpfs":
|
||||||
|
if volume.Bind != nil {
|
||||||
|
logrus.Warnf("mount of type `tmpfs` should not define `bind` option")
|
||||||
|
}
|
||||||
|
if volume.Tmpfs != nil {
|
||||||
|
logrus.Warnf("mount of type `tmpfs` should not define `volumeZ` option")
|
||||||
|
}
|
||||||
|
return nil, nil, buildTmpfsOptions(volume.Tmpfs)
|
||||||
|
}
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func buildBindOption(bind *types.ServiceVolumeBind) *mount.BindOptions {
|
func buildBindOption(bind *types.ServiceVolumeBind) *mount.BindOptions {
|
||||||
if bind == nil {
|
if bind == nil {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user