MCPcopy Create free account
hub / github.com/docker/cli / resolveVolumePaths

Function resolveVolumePaths

cli/compose/loader/loader.go:486–510  ·  view source on GitHub ↗
(volumes []types.ServiceVolumeConfig, workingDir string, lookupEnv template.Mapping)

Source from the content-addressed store, hash-verified

484}
485
486func resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string, lookupEnv template.Mapping) error {
487 for i, volume := range volumes {
488 if volume.Type != "bind" {
489 continue
490 }
491
492 if volume.Source == "" {
493 return errors.New(`invalid mount config for type "bind": field Source must not be empty`)
494 }
495
496 filePath := expandUser(volume.Source, lookupEnv)
497 // Check if source is an absolute path (either Unix or Windows), to
498 // handle a Windows client with a Unix daemon or vice-versa.
499 //
500 // Note that this is not required for Docker for Windows when specifying
501 // a local Windows path, because Docker for Windows translates the Windows
502 // path into a valid path within the VM.
503 if !path.IsAbs(filePath) && !isAbs(filePath) {
504 filePath = absPath(workingDir, filePath)
505 }
506 volume.Source = filePath
507 volumes[i] = volume
508 }
509 return nil
510}
511
512// TODO: make this more robust
513func expandUser(srcPath string, lookupEnv template.Mapping) string {

Callers 1

LoadServiceFunction · 0.85

Calls 3

expandUserFunction · 0.85
absPathFunction · 0.85
isAbsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…