MCPcopy
hub / github.com/containerd/containerd / createContentStore

Function createContentStore

core/metadata/content_test.go:40–76  ·  view source on GitHub ↗
(ctx context.Context, root string, opts ...DBOpt)

Source from the content-addressed store, hash-verified

38)
39
40func createContentStore(ctx context.Context, root string, opts ...DBOpt) (context.Context, content.Store, func() error, error) {
41 // TODO: Use mocked or in-memory store
42 cs, err := local.NewStore(root)
43 if err != nil {
44 return nil, nil, nil, err
45 }
46
47 db, err := bolt.Open(filepath.Join(root, "metadata.db"), 0660, nil)
48 if err != nil {
49 return nil, nil, nil, err
50 }
51
52 var (
53 count atomic.Uint64
54 name = testsuite.Name(ctx)
55 )
56 wrap := func(ctx context.Context, sharedNS bool) (context.Context, func(context.Context) error, error) {
57 n := count.Add(1)
58 ctx2 := namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, n))
59 if sharedNS {
60 db.Update(func(tx *bolt.Tx) error {
61 if ns, err := namespaces.NamespaceRequired(ctx2); err == nil {
62 return NewNamespaceStore(tx).SetLabel(ctx2, ns, labels.LabelSharedNamespace, "true")
63 }
64 return err
65 })
66 }
67 return ctx2, func(context.Context) error {
68 return nil
69 }, nil
70 }
71 ctx = testsuite.SetContextWrapper(ctx, wrap)
72
73 return ctx, NewDB(db, cs, nil, opts...).ContentStore(), func() error {
74 return db.Close()
75 }, nil
76}
77
78func createContentStoreWithPolicy(opts ...DBOpt) testsuite.StoreInitFn {
79 return func(ctx context.Context, root string) (context.Context, content.Store, func() error, error) {

Callers 1

Calls 13

NewStoreFunction · 0.92
NameFunction · 0.92
WithNamespaceFunction · 0.92
NamespaceRequiredFunction · 0.92
SetContextWrapperFunction · 0.92
NewNamespaceStoreFunction · 0.85
NewDBFunction · 0.85
AddMethod · 0.65
UpdateMethod · 0.65
SetLabelMethod · 0.65
ContentStoreMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…