Skip to content

Commit

Permalink
Merge pull request #1 from PlayEveryWare/mendsley/snapshot_labels
Browse files Browse the repository at this point in the history
Forward all labels to the snapshotter
  • Loading branch information
mendsley authored Nov 1, 2024
2 parents 770454e + 3e508b4 commit 20ffba7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions daemon/containerd/image_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

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

_, err = snapshotter.Prepare(ctx, id, id+"-init")
sops := []snapshots.Opt {
snapshots.WithLabels(labels),
}
_, err = snapshotter.Prepare(ctx, id, id+"-init", sops...)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion daemon/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (daemon *Daemon) create(ctx context.Context, daemonCfg *config.Config, opts
ctr.ImageManifest = imgManifest

if daemon.UsesSnapshotter() {
if err := daemon.imageService.PrepareSnapshot(ctx, ctr.ID, opts.params.Config.Image, opts.params.Platform, setupInitLayer(daemon.idMapping)); err != nil {
if err := daemon.imageService.PrepareSnapshot(ctx, ctr.ID, opts.params.Config.Image, opts.params.Platform, setupInitLayer(daemon.idMapping), opts.params.Config.Labels); err != nil {
return nil, err
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion daemon/image_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ImageService interface {

// Containerd related methods

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

// Layers
Expand Down
2 changes: 1 addition & 1 deletion daemon/images/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type manifest struct {
Config ocispec.Descriptor `json:"config"`
}

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

0 comments on commit 20ffba7

Please sign in to comment.