MCPcopy
hub / github.com/containerd/containerd / newContentStore

Function newContentStore

integration/client/content_test.go:32–81  ·  view source on GitHub ↗
(ctx context.Context, root string)

Source from the content-addressed store, hash-verified

30)
31
32func newContentStore(ctx context.Context, root string) (context.Context, content.Store, func() error, error) {
33 client, err := New(address)
34 if err != nil {
35 return nil, nil, nil, err
36 }
37
38 var (
39 count atomic.Uint64
40 cs = client.ContentStore()
41 name = testsuite.Name(ctx)
42 )
43
44 wrap := func(ctx context.Context, sharedNS bool) (context.Context, func(context.Context) error, error) {
45 n := count.Add(1)
46 ctx = namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, n))
47 return client.WithLease(ctx)
48 }
49
50 ctx = testsuite.SetContextWrapper(ctx, wrap)
51
52 return ctx, cs, func() error {
53 for i := uint64(1); i <= count.Load(); i++ {
54 ctx = namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, i))
55 statuses, err := cs.ListStatuses(ctx)
56 if err != nil {
57 return err
58 }
59 for _, st := range statuses {
60 if err := cs.Abort(ctx, st.Ref); err != nil && !errdefs.IsNotFound(err) {
61 return fmt.Errorf("failed to abort %s: %w", st.Ref, err)
62 }
63 }
64 err = cs.Walk(ctx, func(info content.Info) error {
65 if err := cs.Delete(ctx, info.Digest); err != nil {
66 if errdefs.IsNotFound(err) {
67 return nil
68 }
69
70 return err
71 }
72 return nil
73 })
74 if err != nil {
75 return err
76 }
77 }
78 return nil
79
80 }, nil
81}
82
83func TestContentClient(t *testing.T) {
84 if testing.Short() {

Callers

nothing calls this directly

Calls 12

NameFunction · 0.92
WithNamespaceFunction · 0.92
SetContextWrapperFunction · 0.92
LoadMethod · 0.80
ContentStoreMethod · 0.65
AddMethod · 0.65
WithLeaseMethod · 0.65
ListStatusesMethod · 0.65
AbortMethod · 0.65
WalkMethod · 0.65
DeleteMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…