MCPcopy
hub / github.com/docker/compose / buildMountOptions

Function buildMountOptions

pkg/compose/create.go:1242–1267  ·  view source on GitHub ↗
(volume types.ServiceVolumeConfig)

Source from the content-addressed store, hash-verified

1240}
1241
1242func buildMountOptions(volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions, *mount.ImageOptions) {
1243 if volume.Type != types.VolumeTypeBind && volume.Bind != nil {
1244 logrus.Warnf("mount of type `%s` should not define `bind` option", volume.Type)
1245 }
1246 if volume.Type != types.VolumeTypeVolume && volume.Volume != nil {
1247 logrus.Warnf("mount of type `%s` should not define `volume` option", volume.Type)
1248 }
1249 if volume.Type != types.VolumeTypeTmpfs && volume.Tmpfs != nil {
1250 logrus.Warnf("mount of type `%s` should not define `tmpfs` option", volume.Type)
1251 }
1252 if volume.Type != types.VolumeTypeImage && volume.Image != nil {
1253 logrus.Warnf("mount of type `%s` should not define `image` option", volume.Type)
1254 }
1255
1256 switch volume.Type {
1257 case "bind":
1258 return buildBindOption(volume.Bind), nil, nil, nil
1259 case "volume":
1260 return nil, buildVolumeOptions(volume.Volume), nil, nil
1261 case "tmpfs":
1262 return nil, nil, buildTmpfsOptions(volume.Tmpfs), nil
1263 case "image":
1264 return nil, nil, nil, buildImageOptions(volume.Image)
1265 }
1266 return nil, nil, nil, nil
1267}
1268
1269func buildBindOption(bind *types.ServiceVolumeBind) *mount.BindOptions {
1270 if bind == nil {

Callers 1

buildMountFunction · 0.85

Calls 4

buildBindOptionFunction · 0.85
buildVolumeOptionsFunction · 0.85
buildTmpfsOptionsFunction · 0.85
buildImageOptionsFunction · 0.85

Tested by

no test coverage detected