(volumes []types.ServiceVolumeConfig, workingDir string, lookupEnv template.Mapping)
| 484 | } |
| 485 | |
| 486 | func 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 |
| 513 | func expandUser(srcPath string, lookupEnv template.Mapping) string { |
no test coverage detected
searching dependent graphs…