diff: resplit Applier from Differ

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2017-11-13 06:46:29 +00:00
committed by Derek McGowan
parent b268261446
commit b580441f91
7 changed files with 36 additions and 21 deletions

View File

@@ -24,21 +24,33 @@ type Config struct {
// Opt is used to configure a diff operation
type Opt func(*Config) error
// Differ allows the apply and creation of filesystem diffs between mounts
// Differ allows creation of filesystem diffs between mounts
type Differ interface {
// Diff computes the difference between two mounts and returns a
// descriptor for the computed diff. The options can provide
// a ref which can be used to track the content creation of the diff.
// The media type which is used to determine the format of the created
// content can also be provided as an option.
Diff(ctx context.Context, lower, upper []mount.Mount, opts ...Opt) (ocispec.Descriptor, error)
}
// Applier allows applying diffs between mounts
type Applier interface {
// Apply applies the content referred to by the given descriptor to
// the provided mount. The method of applying is based on the
// implementation and content descriptor. For example, in the common
// case the descriptor is a file system difference in tar format,
// that tar would be applied on top of the mounts.
Apply(ctx context.Context, desc ocispec.Descriptor, mount []mount.Mount) (ocispec.Descriptor, error)
}
// DiffMounts computes the difference between two mounts and returns a
// descriptor for the computed diff. The options can provide
// a ref which can be used to track the content creation of the diff.
// The media type which is used to determine the format of the created
// content can also be provided as an option.
DiffMounts(ctx context.Context, lower, upper []mount.Mount, opts ...Opt) (ocispec.Descriptor, error)
// DiffApplier is the interface that groups the basic Apply and Diff methods.
//
// golint says `type name will be used as diff.DiffApplier by other packages, and that stutters`,
// but that can be ignored now.
type DiffApplier interface { // nolint: golint
Applier
Differ
}
// WithMediaType sets the media type to use for creating the diff, without