(ctx context.Context, snapshotterName string, opts ...UnpackOpt)
| 299 | } |
| 300 | |
| 301 | func (i *image) Unpack(ctx context.Context, snapshotterName string, opts ...UnpackOpt) error { |
| 302 | ctx, done, err := i.client.WithLease(ctx) |
| 303 | if err != nil { |
| 304 | return err |
| 305 | } |
| 306 | defer done(ctx) |
| 307 | |
| 308 | var config UnpackConfig |
| 309 | for _, o := range opts { |
| 310 | if err := o(ctx, &config); err != nil { |
| 311 | return err |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | manifest, err := i.getManifest(ctx, i.platform) |
| 316 | if err != nil { |
| 317 | return err |
| 318 | } |
| 319 | |
| 320 | layers, err := i.getLayers(ctx, manifest) |
| 321 | if err != nil { |
| 322 | return err |
| 323 | } |
| 324 | |
| 325 | var ( |
| 326 | a = i.client.DiffService() |
| 327 | cs = i.client.ContentStore() |
| 328 | |
| 329 | chain []digest.Digest |
| 330 | unpacked bool |
| 331 | ) |
| 332 | snapshotterName, err = i.client.resolveSnapshotterName(ctx, snapshotterName) |
| 333 | if err != nil { |
| 334 | return err |
| 335 | } |
| 336 | sn, err := i.client.getSnapshotter(ctx, snapshotterName) |
| 337 | if err != nil { |
| 338 | return err |
| 339 | } |
| 340 | |
| 341 | if err := i.checkSnapshotterSupport(ctx, snapshotterName, manifest, |
| 342 | config.CheckPlatformSupported); err != nil { |
| 343 | return err |
| 344 | } |
| 345 | |
| 346 | for _, layer := range layers { |
| 347 | unpacked, err = rootfs.ApplyLayerWithOpts(ctx, layer, chain, sn, a, config.SnapshotOpts, config.ApplyOpts) |
| 348 | if err != nil { |
| 349 | return fmt.Errorf("apply layer error for %q: %w", i.Name(), err) |
| 350 | } |
| 351 | |
| 352 | if unpacked { |
| 353 | // Set the uncompressed label after the uncompressed |
| 354 | // digest has been verified through apply. |
| 355 | cinfo := content.Info{ |
| 356 | Digest: layer.Blob.Digest, |
| 357 | Labels: map[string]string{ |
| 358 | labels.LabelUncompressed: layer.Diff.Digest.String(), |
nothing calls this directly
no test coverage detected