MCPcopy
hub / github.com/containerd/containerd / withImage

Function withImage

integration/client/mount_manager_linux_test.go:240–278  ·  view source on GitHub ↗
(image containerd.Image, args ...string)

Source from the content-addressed store, hash-verified

238}
239
240func withImage(image containerd.Image, args ...string) oci.SpecOpts {
241 return func(ctx context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
242 ic, err := image.Config(ctx)
243 if err != nil {
244 return err
245 }
246 if !images.IsConfigType(ic.MediaType) {
247 return fmt.Errorf("unknown image config media type %s", ic.MediaType)
248 }
249
250 var (
251 imageConfigBytes []byte
252 ociimage v1.Image
253 )
254 imageConfigBytes, err = content.ReadBlob(ctx, image.ContentStore(), ic)
255 if err != nil {
256 return err
257 }
258
259 if err = json.Unmarshal(imageConfigBytes, &ociimage); err != nil {
260 return err
261 }
262 if s.Linux == nil {
263 return fmt.Errorf("linux image section missing")
264 }
265
266 s.Process = &specs.Process{}
267 s.Process.Env = ociimage.Config.Env
268 s.Process.Args = append(ociimage.Config.Entrypoint, args...)
269
270 cwd := ociimage.Config.WorkingDir
271 if cwd == "" {
272 cwd = "/"
273 }
274 s.Process.Cwd = cwd
275
276 return nil
277 }
278}

Callers 1

TestMountAtRuntimeFunction · 0.85

Calls 5

IsConfigTypeFunction · 0.92
ReadBlobFunction · 0.92
UnmarshalMethod · 0.80
ConfigMethod · 0.65
ContentStoreMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…