(mounts []mount.Mount)
| 321 | } |
| 322 | |
| 323 | func mountsToLayerAndParents(mounts []mount.Mount) (string, []string, error) { |
| 324 | if len(mounts) != 1 { |
| 325 | return "", nil, fmt.Errorf("number of mounts should always be 1 for Windows layers: %w", errdefs.ErrInvalidArgument) |
| 326 | } |
| 327 | mnt := mounts[0] |
| 328 | |
| 329 | if mnt.Type != "windows-layer" { |
| 330 | // This is a special case error. When this is received the diff service |
| 331 | // will attempt the next differ in the chain which for Windows is the |
| 332 | // lcow differ that we want. |
| 333 | return "", nil, fmt.Errorf("windowsDiff does not support layer type %s: %w", mnt.Type, errdefs.ErrNotImplemented) |
| 334 | } |
| 335 | |
| 336 | parentLayerPaths, err := mnt.GetParentPaths() |
| 337 | if err != nil { |
| 338 | return "", nil, err |
| 339 | } |
| 340 | |
| 341 | if mnt.ReadOnly() { |
| 342 | if len(parentLayerPaths) == 0 { |
| 343 | // rootfs.CreateDiff creates a new, empty View to diff against, |
| 344 | // when diffing something with no parent. |
| 345 | // This makes perfect sense for a walking Diff, but for WCOW, |
| 346 | // we have to recognise this as "diff against nothing" |
| 347 | return "", nil, nil |
| 348 | } |
| 349 | // Ignore the dummy sandbox. |
| 350 | return parentLayerPaths[0], parentLayerPaths[1:], nil |
| 351 | } |
| 352 | return mnt.Source, parentLayerPaths, nil |
| 353 | } |
| 354 | |
| 355 | // mountPairToLayerStack ensures that the two sets of mount-lists are actually a correct |
| 356 | // parent-and-child, or orphan-and-empty-list, and return the full list of layers, starting |
no test coverage detected
searching dependent graphs…