Merge pull request #1485 from AkihiroSuda/expose-differ

differ: expose newWalkingDiff() for standalone buildkit
This commit is contained in:
Michael Crosby 2017-09-11 14:31:16 -04:00 committed by GitHub
commit a2aa4ecdc0

View File

@ -38,7 +38,7 @@ func init() {
if err != nil { if err != nil {
return nil, err 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{} 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{ return &walkingDiff{
store: store, store: store,
}, nil }, 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) { func (s *walkingDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount) (ocispec.Descriptor, error) {
var isCompressed bool var isCompressed bool
switch desc.MediaType { switch desc.MediaType {
@ -118,6 +123,8 @@ func (s *walkingDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts
}, nil }, 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) { func (s *walkingDiff) DiffMounts(ctx context.Context, lower, upper []mount.Mount, media, ref string) (ocispec.Descriptor, error) {
var isCompressed bool var isCompressed bool
switch media { switch media {