diff: rename differ to comparer

Remove combined interface and split implementations.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-12-19 15:47:48 -08:00
parent b580441f91
commit b763777288
12 changed files with 217 additions and 151 deletions

View File

@@ -1,9 +1,10 @@
package diff
import (
"context"
"github.com/containerd/containerd/mount"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context"
)
// Config is used to hold parameters needed for a diff operation
@@ -24,14 +25,14 @@ type Config struct {
// Opt is used to configure a diff operation
type Opt func(*Config) error
// Differ allows creation of filesystem diffs between mounts
type Differ interface {
// Diff computes the difference between two mounts and returns a
// Comparer allows creation of filesystem diffs between mounts
type Comparer interface {
// Compare 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)
Compare(ctx context.Context, lower, upper []mount.Mount, opts ...Opt) (ocispec.Descriptor, error)
}
// Applier allows applying diffs between mounts
@@ -44,15 +45,6 @@ type Applier interface {
Apply(ctx context.Context, desc ocispec.Descriptor, mount []mount.Mount) (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
// specifying the differ will choose a default.
func WithMediaType(m string) Opt {