(image containerd.Image, args ...string)
| 238 | } |
| 239 | |
| 240 | func 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 | } |
no test coverage detected
searching dependent graphs…