(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…