MCPcopy Create free account
hub / github.com/containers/common / filterContainers

Function filterContainers

libimage/filters.go:328–351  ·  view source on GitHub ↗

filterContainers creates a container filter for matching the specified value.

(value string, fn IsExternalContainerFunc)

Source from the content-addressed store, hash-verified

326
327// filterContainers creates a container filter for matching the specified value.
328func 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.
354func filterDangling(ctx context.Context, value bool, tree *layerTree) filterFunc {

Callers 1

compileImageFiltersMethod · 0.85

Calls 1

ContainersMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…