pathOnHost will return the *host* location of a container path, accounting for volumes. The provided path must be fully resolved, as returned by `resolvePath`.
(path string)
| 255 | // pathOnHost will return the *host* location of a container path, accounting for volumes. |
| 256 | // The provided path must be fully resolved, as returned by `resolvePath`. |
| 257 | func (res *resolver) pathOnHost(path string) string { |
| 258 | hostRoot := res.hostRoot |
| 259 | path = filepath.Clean(path) |
| 260 | itemized := strings.Split(path, string(os.PathSeparator)) |
| 261 | |
| 262 | containerRoot := "/" |
| 263 | sub := itemized |
| 264 | |
| 265 | for _, mnt := range res.mounts { |
| 266 | if candidateIsParent, subPath := isParent(itemized, strings.Split(mnt.Destination, string(os.PathSeparator))); candidateIsParent { |
| 267 | if len(mnt.Destination) > len(containerRoot) { |
| 268 | containerRoot = mnt.Destination |
| 269 | hostRoot = mnt.Source |
| 270 | sub = subPath |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | return filepath.Join(append([]string{hostRoot}, sub...)...) |
| 276 | } |
| 277 | |
| 278 | // getMount returns the mount locator for a given fully-resolved path, along with the corresponding subpath of the path |
| 279 | // relative to the locator |