filterContainers creates a container filter for matching the specified value.
(value string, fn IsExternalContainerFunc)
| 326 | |
| 327 | // filterContainers creates a container filter for matching the specified value. |
| 328 | func filterContainers(value string, fn IsExternalContainerFunc) filterFunc { |
| 329 | return func(img *Image) (bool, error) { |
| 330 | ctrs, err := img.Containers() |
| 331 | if err != nil { |
| 332 | return false, err |
| 333 | } |
| 334 | if value != "external" { |
| 335 | boolValue := value == "true" |
| 336 | return (len(ctrs) > 0) == boolValue, nil |
| 337 | } |
| 338 | |
| 339 | // Check whether all associated containers are external ones. |
| 340 | for _, c := range ctrs { |
| 341 | isExternal, err := fn(c) |
| 342 | if err != nil { |
| 343 | return false, fmt.Errorf("checking if %s is an external container in filter: %w", c, err) |
| 344 | } |
| 345 | if !isExternal { |
| 346 | return isExternal, nil |
| 347 | } |
| 348 | } |
| 349 | return true, nil |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | // filterDangling creates a dangling filter for matching the specified value. |
| 354 | func filterDangling(ctx context.Context, value bool, tree *layerTree) filterFunc { |
no test coverage detected
searching dependent graphs…