MCPcopy Index your code
hub / github.com/containerd/containerd / TestWithImageConfigLabels

Function TestWithImageConfigLabels

client/container_opts_test.go:48–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestWithImageConfigLabels(t *testing.T) {
49 blob, err := json.Marshal(ocispec.Image{
50 Config: ocispec.ImageConfig{
51 Labels: map[string]string{
52 "foo": "bar",
53 "containerd.io/restart.policy": "always",
54 "io.cri-containerd.kind": "sandbox",
55 },
56 },
57 })
58 require.NoError(t, err)
59
60 img := fakeImage{
61 config: ocispec.Descriptor{
62 MediaType: ocispec.MediaTypeImageConfig,
63 Digest: digest.FromBytes(blob),
64 Size: int64(len(blob)),
65 Data: blob,
66 },
67 }
68
69 var c containers.Container
70 require.NoError(t, WithImageConfigLabels(img)(t.Context(), nil, &c))
71
72 // labels in the namespaces reserved for containerd and the CRI plugin
73 // are not copied from the image config
74 assert.Equal(t, map[string]string{"foo": "bar"}, c.Labels)
75}

Callers

nothing calls this directly

Calls 3

WithImageConfigLabelsFunction · 0.85
MarshalMethod · 0.45
ContextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…