( h images.Handler, config ocispec.Descriptor, layers []ocispec.Descriptor, )
| 301 | } |
| 302 | |
| 303 | func (u *Unpacker) unpack( |
| 304 | h images.Handler, |
| 305 | config ocispec.Descriptor, |
| 306 | layers []ocispec.Descriptor, |
| 307 | ) error { |
| 308 | ctx := u.ctx |
| 309 | ctx, layerSpan := tracing.StartSpan(ctx, tracing.Name(unpackSpanPrefix, "unpack")) |
| 310 | defer layerSpan.End() |
| 311 | unpackStart := time.Now() |
| 312 | p, err := content.ReadBlob(ctx, u.content, config) |
| 313 | if err != nil { |
| 314 | return err |
| 315 | } |
| 316 | |
| 317 | var i unpackConfig |
| 318 | if err := json.Unmarshal(p, &i); err != nil { |
| 319 | return fmt.Errorf("unmarshal image config: %w", err) |
| 320 | } |
| 321 | |
| 322 | diffIDs := i.RootFS.DiffIDs |
| 323 | if len(layers) != len(diffIDs) { |
| 324 | return fmt.Errorf("number of layers and diffIDs don't match: %d != %d", len(layers), len(diffIDs)) |
| 325 | } |
| 326 | |
| 327 | // TODO: Support multiple unpacks rather than just first match |
| 328 | var unpack *Platform |
| 329 | |
| 330 | imgPlatform := platforms.Normalize(i.Platform) |
| 331 | for _, up := range u.platforms { |
| 332 | if up.ConfigType != "" && up.ConfigType != config.MediaType { |
| 333 | continue |
| 334 | } |
| 335 | // "layers" is only supported rootfs value for OCI images |
| 336 | if (up.ConfigType == "" || images.IsConfigType(up.ConfigType)) && i.RootFS.Type != "" && i.RootFS.Type != "layers" { |
| 337 | continue |
| 338 | } |
| 339 | if up.Platform.Match(imgPlatform) { |
| 340 | unpack = up |
| 341 | break |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if unpack == nil { |
| 346 | log.G(ctx).WithField("image", config.Digest).WithField("platform", platforms.Format(imgPlatform)).Debugf("unpacker does not support platform, only fetching layers") |
| 347 | return u.fetch(ctx, h, layers, nil) |
| 348 | } |
| 349 | |
| 350 | u.unpacks.Add(1) |
| 351 | |
| 352 | var ( |
| 353 | sn = unpack.Snapshotter |
| 354 | a = unpack.Applier |
| 355 | cs = u.content |
| 356 | |
| 357 | fetchOffset int |
| 358 | fetchC []chan struct{} |
| 359 | fetchErr []chan error |
| 360 |
no test coverage detected