(ctx context.Context, fs ...string)
| 79 | } |
| 80 | |
| 81 | func (s *containerStore) List(ctx context.Context, fs ...string) ([]containers.Container, error) { |
| 82 | namespace, err := namespaces.NamespaceRequired(ctx) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | |
| 87 | filter, err := filters.ParseAll(fs...) |
| 88 | if err != nil { |
| 89 | return nil, fmt.Errorf("%s: %w", err.Error(), errdefs.ErrInvalidArgument) |
| 90 | } |
| 91 | |
| 92 | var m []containers.Container |
| 93 | |
| 94 | if err := view(ctx, s.db, func(tx *bolt.Tx) error { |
| 95 | bkt := getContainersBucket(tx, namespace) |
| 96 | if bkt == nil { |
| 97 | return nil // empty store |
| 98 | } |
| 99 | |
| 100 | return bkt.ForEach(func(k, v []byte) error { |
| 101 | cbkt := bkt.Bucket(k) |
| 102 | if cbkt == nil { |
| 103 | return nil |
| 104 | } |
| 105 | container := containers.Container{ID: string(k)} |
| 106 | |
| 107 | if err := readContainer(&container, cbkt); err != nil { |
| 108 | return fmt.Errorf("failed to read container %q: %w", string(k), err) |
| 109 | } |
| 110 | |
| 111 | if filter.Match(adaptContainer(container)) { |
| 112 | m = append(m, container) |
| 113 | } |
| 114 | return nil |
| 115 | }) |
| 116 | }); err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | |
| 120 | return m, nil |
| 121 | } |
| 122 | |
| 123 | func (s *containerStore) Create(ctx context.Context, container containers.Container) (containers.Container, error) { |
| 124 | ctx, span := tracing.StartSpan(ctx, |
nothing calls this directly
no test coverage detected