Skip to content

Commit 20ffba7

Browse files
authored
Merge pull request #1 from PlayEveryWare/mendsley/snapshot_labels
Forward all labels to the snapshotter
2 parents 770454e + 3e508b4 commit 20ffba7

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

daemon/containerd/image_snapshot.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
// PrepareSnapshot prepares a snapshot from a parent image for a container
21-
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error) error {
21+
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error, labels map[string]string) error {
2222
var parentSnapshot string
2323
if parentImage != "" {
2424
img, err := i.resolveImage(ctx, parentImage)
@@ -72,7 +72,10 @@ func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentIma
7272
return i.remapSnapshot(ctx, snapshotter, id, id+"-init")
7373
}
7474

75-
_, err = snapshotter.Prepare(ctx, id, id+"-init")
75+
sops := []snapshots.Opt {
76+
snapshots.WithLabels(labels),
77+
}
78+
_, err = snapshotter.Prepare(ctx, id, id+"-init", sops...)
7679
return err
7780
}
7881

daemon/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (daemon *Daemon) create(ctx context.Context, daemonCfg *config.Config, opts
197197
ctr.ImageManifest = imgManifest
198198

199199
if daemon.UsesSnapshotter() {
200-
if err := daemon.imageService.PrepareSnapshot(ctx, ctr.ID, opts.params.Config.Image, opts.params.Platform, setupInitLayer(daemon.idMapping)); err != nil {
200+
if err := daemon.imageService.PrepareSnapshot(ctx, ctr.ID, opts.params.Config.Image, opts.params.Platform, setupInitLayer(daemon.idMapping), opts.params.Config.Labels); err != nil {
201201
return nil, err
202202
}
203203
} else {

daemon/image_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type ImageService interface {
4747

4848
// Containerd related methods
4949

50-
PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error) error
50+
PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error, labels map[string]string) error
5151
GetImageManifest(ctx context.Context, refOrID string, options backend.GetImageOpts) (*ocispec.Descriptor, error)
5252

5353
// Layers

daemon/images/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type manifest struct {
4545
Config ocispec.Descriptor `json:"config"`
4646
}
4747

48-
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error) error {
48+
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error, labels map[string]string) error {
4949
// Only makes sense when containerd image store is used
5050
panic("not implemented")
5151
}

0 commit comments

Comments
 (0)