From 1310c859c713d08e17eb252f1b9be86537010fde Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 7 Sep 2017 09:04:09 +0000 Subject: [PATCH] differ: expose newWalkingDiff() for standalone buildkit Signed-off-by: Akihiro Suda --- differ/differ.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/differ/differ.go b/differ/differ.go index 60e5d3eea..fc5a690e6 100644 --- a/differ/differ.go +++ b/differ/differ.go @@ -38,7 +38,7 @@ func init() { if err != nil { return nil, err } - return newWalkingDiff(metadata.NewContentStore(md.(*bolt.DB), c.(content.Store))) + return NewWalkingDiff(metadata.NewContentStore(md.(*bolt.DB), c.(content.Store))) }, }) } @@ -49,12 +49,17 @@ type walkingDiff struct { var emptyDesc = ocispec.Descriptor{} -func newWalkingDiff(store content.Store) (plugin.Differ, error) { +// NewWalkingDiff is a generic implementation of plugin.Differ. +// NewWalkingDiff is expected to work with any filesystem. +func NewWalkingDiff(store content.Store) (plugin.Differ, error) { return &walkingDiff{ store: store, }, nil } +// Apply applies the content associated with the provided digests onto the +// provided mounts. Archive content will be extracted and decompressed if +// necessary. func (s *walkingDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount) (ocispec.Descriptor, error) { var isCompressed bool switch desc.MediaType { @@ -118,6 +123,8 @@ func (s *walkingDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts }, nil } +// DiffMounts creates a diff between the given mounts and uploads the result +// to the content store. func (s *walkingDiff) DiffMounts(ctx context.Context, lower, upper []mount.Mount, media, ref string) (ocispec.Descriptor, error) { var isCompressed bool switch media {