diff --git a/api/next.pb.txt b/api/next.pb.txt index 6343a3de5..a27162c15 100755 --- a/api/next.pb.txt +++ b/api/next.pb.txt @@ -2793,7 +2793,7 @@ file { syntax: "proto3" } file { - name: "github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto" + name: "github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto" package: "containerd.services.snapshots.v1" dependency: "gogoproto/gogo.proto" dependency: "google/protobuf/empty.proto" @@ -3317,7 +3317,7 @@ file { } } options { - go_package: "github.com/containerd/containerd/api/services/snapshot/v1;snapshot" + go_package: "github.com/containerd/containerd/api/services/snapshots/v1;snapshots" } weak_dependency: 0 syntax: "proto3" diff --git a/api/services/snapshot/v1/snapshots.pb.go b/api/services/snapshots/v1/snapshots.pb.go similarity index 94% rename from api/services/snapshot/v1/snapshots.pb.go rename to api/services/snapshots/v1/snapshots.pb.go index bfd4a0438..4cf68f0d8 100644 --- a/api/services/snapshot/v1/snapshots.pb.go +++ b/api/services/snapshots/v1/snapshots.pb.go @@ -1,11 +1,11 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto +// source: github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto /* - Package snapshot is a generated protocol buffer package. + Package snapshots is a generated protocol buffer package. It is generated from these files: - github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto + github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto It has these top-level messages: PrepareSnapshotRequest @@ -26,7 +26,7 @@ UsageRequest UsageResponse */ -package snapshot +package snapshots import proto "github.com/gogo/protobuf/proto" import fmt "fmt" @@ -651,7 +651,7 @@ var _Snapshots_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto", + Metadata: "github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto", } func (m *PrepareSnapshotRequest) Marshal() (dAtA []byte, err error) { @@ -4194,72 +4194,72 @@ var ( ) func init() { - proto.RegisterFile("github.com/containerd/containerd/api/services/snapshot/v1/snapshots.proto", fileDescriptorSnapshots) + proto.RegisterFile("github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto", fileDescriptorSnapshots) } var fileDescriptorSnapshots = []byte{ - // 1006 bytes of a gzipped FileDescriptorProto + // 1007 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 0x1a, 0x47, 0x14, 0x67, 0x60, 0x8d, 0xe3, 0x87, 0xed, 0xd2, 0x09, 0x26, 0x68, 0x5b, 0xe1, 0x15, 0x87, 0xca, - 0xea, 0x61, 0x37, 0xa1, 0x6a, 0xe2, 0xc4, 0x97, 0x02, 0xa1, 0x15, 0x71, 0xec, 0x54, 0x1b, 0xdb, - 0x89, 0xd3, 0x48, 0xd1, 0x1a, 0xc6, 0x78, 0x05, 0xbb, 0x4b, 0x99, 0x81, 0x88, 0x56, 0xaa, 0x7a, - 0x8c, 0x7c, 0xea, 0x17, 0xf0, 0xa9, 0xfd, 0x10, 0x55, 0x3f, 0x81, 0x8f, 0x3d, 0xf6, 0xd4, 0x36, - 0xfe, 0x12, 0x3d, 0xf5, 0x8f, 0x66, 0x76, 0x16, 0x30, 0xa6, 0x62, 0xc1, 0xe4, 0xf6, 0x76, 0x66, - 0xde, 0x7b, 0xbf, 0xf7, 0x7b, 0xf3, 0xde, 0x9b, 0x85, 0x4a, 0xdd, 0x66, 0x27, 0x9d, 0x23, 0xbd, - 0xea, 0x39, 0x46, 0xd5, 0x73, 0x99, 0x65, 0xbb, 0xa4, 0x5d, 0x1b, 0x16, 0xad, 0x96, 0x6d, 0x50, - 0xd2, 0xee, 0xda, 0x55, 0x42, 0x0d, 0xea, 0x5a, 0x2d, 0x7a, 0xe2, 0x31, 0xa3, 0x7b, 0xa7, 0x2f, - 0x53, 0xbd, 0xd5, 0xf6, 0x98, 0x87, 0x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bf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xa0, 0xb2, 0xda, 0xc4, 0x0e, 0x00, 0x00, } diff --git a/api/services/snapshot/v1/snapshots.proto b/api/services/snapshots/v1/snapshots.proto similarity index 99% rename from api/services/snapshot/v1/snapshots.proto rename to api/services/snapshots/v1/snapshots.proto index 8caafc904..0e62add3b 100644 --- a/api/services/snapshot/v1/snapshots.proto +++ b/api/services/snapshots/v1/snapshots.proto @@ -8,7 +8,7 @@ import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; import "github.com/containerd/containerd/api/types/mount.proto"; -option go_package = "github.com/containerd/containerd/api/services/snapshot/v1;snapshot"; +option go_package = "github.com/containerd/containerd/api/services/snapshots/v1;snapshots"; // Snapshot service manages snapshots service Snapshots { diff --git a/client.go b/client.go index f340e9509..5c20335ea 100644 --- a/client.go +++ b/client.go @@ -17,7 +17,7 @@ import ( imagesapi "github.com/containerd/containerd/api/services/images/v1" introspectionapi "github.com/containerd/containerd/api/services/introspection/v1" namespacesapi "github.com/containerd/containerd/api/services/namespaces/v1" - snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" + snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/services/tasks/v1" versionservice "github.com/containerd/containerd/api/services/version/v1" "github.com/containerd/containerd/containers" @@ -33,7 +33,7 @@ import ( "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/schema1" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/containerd/typeurl" ptypes "github.com/gogo/protobuf/types" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -435,8 +435,8 @@ func (c *Client) ContentStore() content.Store { } // SnapshotService returns the underlying snapshotter for the provided snapshotter name -func (c *Client) SnapshotService(snapshotterName string) snapshot.Snapshotter { - return NewSnapshotterFromClient(snapshotapi.NewSnapshotsClient(c.conn), snapshotterName) +func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter { + return NewSnapshotterFromClient(snapshotsapi.NewSnapshotsClient(c.conn), snapshotterName) } // TaskService returns the underlying TasksClient diff --git a/cmd/containerd/builtins.go b/cmd/containerd/builtins.go index 1a8268ada..9e8bf43cf 100644 --- a/cmd/containerd/builtins.go +++ b/cmd/containerd/builtins.go @@ -13,7 +13,7 @@ import ( _ "github.com/containerd/containerd/services/introspection" _ "github.com/containerd/containerd/services/leases" _ "github.com/containerd/containerd/services/namespaces" - _ "github.com/containerd/containerd/services/snapshot" + _ "github.com/containerd/containerd/services/snapshots" _ "github.com/containerd/containerd/services/tasks" _ "github.com/containerd/containerd/services/version" ) diff --git a/cmd/containerd/builtins_btrfs_linux.go b/cmd/containerd/builtins_btrfs_linux.go index 7a8e54085..e0150581b 100644 --- a/cmd/containerd/builtins_btrfs_linux.go +++ b/cmd/containerd/builtins_btrfs_linux.go @@ -2,4 +2,4 @@ package main -import _ "github.com/containerd/containerd/snapshot/btrfs" +import _ "github.com/containerd/containerd/snapshots/btrfs" diff --git a/cmd/containerd/builtins_linux.go b/cmd/containerd/builtins_linux.go index 1116acc0c..a652f37fb 100644 --- a/cmd/containerd/builtins_linux.go +++ b/cmd/containerd/builtins_linux.go @@ -3,5 +3,5 @@ package main import ( _ "github.com/containerd/containerd/linux" _ "github.com/containerd/containerd/metrics/cgroups" - _ "github.com/containerd/containerd/snapshot/overlay" + _ "github.com/containerd/containerd/snapshots/overlay" ) diff --git a/cmd/containerd/builtins_unix.go b/cmd/containerd/builtins_unix.go index 3983aa7ef..4508be7ac 100644 --- a/cmd/containerd/builtins_unix.go +++ b/cmd/containerd/builtins_unix.go @@ -3,5 +3,5 @@ package main import ( - _ "github.com/containerd/containerd/snapshot/naive" + _ "github.com/containerd/containerd/snapshots/naive" ) diff --git a/cmd/containerd/builtins_windows.go b/cmd/containerd/builtins_windows.go index a1bfa0fc6..381489170 100644 --- a/cmd/containerd/builtins_windows.go +++ b/cmd/containerd/builtins_windows.go @@ -1,6 +1,6 @@ package main import ( - _ "github.com/containerd/containerd/snapshot/windows" + _ "github.com/containerd/containerd/snapshots/windows" _ "github.com/containerd/containerd/windows" ) diff --git a/cmd/ctr/commands/containers/containers.go b/cmd/ctr/commands/containers/containers.go index 5bd9fb456..d0195d4d3 100644 --- a/cmd/ctr/commands/containers/containers.go +++ b/cmd/ctr/commands/containers/containers.go @@ -18,7 +18,7 @@ import ( var Command = cli.Command{ Name: "containers", Usage: "manage containers", - Aliases: []string{"c"}, + Aliases: []string{"c", "container"}, Subcommands: []cli.Command{ deleteCommand, infoCommand, diff --git a/cmd/ctr/commands/events/events.go b/cmd/ctr/commands/events/events.go index 7f74710f3..c347c0f48 100644 --- a/cmd/ctr/commands/events/events.go +++ b/cmd/ctr/commands/events/events.go @@ -15,8 +15,9 @@ import ( // Command is the cli command for displaying containerd events var Command = cli.Command{ - Name: "events", - Usage: "display containerd events", + Name: "events", + Aliases: []string{"event"}, + Usage: "display containerd events", Action: func(context *cli.Context) error { client, ctx, cancel, err := commands.NewClient(context) if err != nil { diff --git a/cmd/ctr/commands/images/images.go b/cmd/ctr/commands/images/images.go index 958c25ef5..7a8a2e99a 100644 --- a/cmd/ctr/commands/images/images.go +++ b/cmd/ctr/commands/images/images.go @@ -19,8 +19,9 @@ import ( // Command is the cli command for managing images var Command = cli.Command{ - Name: "images", - Usage: "manage images", + Name: "images", + Aliases: []string{"image"}, + Usage: "manage images", Subcommands: cli.Commands{ checkCommand, exportCommand, diff --git a/cmd/ctr/commands/namespaces/namespaces.go b/cmd/ctr/commands/namespaces/namespaces.go index bedaf8522..32407dadd 100644 --- a/cmd/ctr/commands/namespaces/namespaces.go +++ b/cmd/ctr/commands/namespaces/namespaces.go @@ -16,8 +16,9 @@ import ( // Command is the cli command for managing namespaces var Command = cli.Command{ - Name: "namespaces", - Usage: "manage namespaces", + Name: "namespaces", + Aliases: []string{"namespace"}, + Usage: "manage namespaces", Subcommands: cli.Commands{ createCommand, listCommand, diff --git a/cmd/ctr/commands/plugins/plugins.go b/cmd/ctr/commands/plugins/plugins.go index 0c8d2228d..1fbee48b7 100644 --- a/cmd/ctr/commands/plugins/plugins.go +++ b/cmd/ctr/commands/plugins/plugins.go @@ -18,8 +18,9 @@ import ( // Command is a cli command that outputs plugin information var Command = cli.Command{ - Name: "plugins", - Usage: "provides information about containerd plugins", + Name: "plugins", + Aliases: []string{"plugin"}, + Usage: "provides information about containerd plugins", Flags: []cli.Flag{ cli.BoolFlag{ Name: "quiet,q", diff --git a/cmd/ctr/commands/snapshot/snapshot.go b/cmd/ctr/commands/snapshots/snapshots.go similarity index 97% rename from cmd/ctr/commands/snapshot/snapshot.go rename to cmd/ctr/commands/snapshots/snapshots.go index 1a54b86f9..ebc769ea5 100644 --- a/cmd/ctr/commands/snapshot/snapshot.go +++ b/cmd/ctr/commands/snapshots/snapshots.go @@ -1,4 +1,4 @@ -package snapshot +package snapshots import ( gocontext "context" @@ -11,7 +11,7 @@ import ( "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/progress" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" digest "github.com/opencontainers/go-digest" "github.com/pkg/errors" "github.com/urfave/cli" @@ -19,9 +19,10 @@ import ( // Command is the cli command for managing snapshots var Command = cli.Command{ - Name: "snapshot", - Usage: "manage snapshots", - Flags: commands.SnapshotterFlags, + Name: "snapshots", + Aliases: []string{"snapshot"}, + Usage: "manage snapshots", + Flags: commands.SnapshotterFlags, Subcommands: cli.Commands{ commitCommand, infoCommand, @@ -52,7 +53,7 @@ var listCommand = cli.Command{ tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0) ) fmt.Fprintln(tw, "KEY\tPARENT\tKIND\t") - if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { + if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error { fmt.Fprintf(tw, "%v\t%v\t%v\t\n", info.Name, info.Parent, @@ -98,7 +99,7 @@ var usageCommand = cli.Command{ ) fmt.Fprintln(tw, "KEY\tSIZE\tINODES\t") if context.NArg() == 0 { - if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { + if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error { usage, err := snapshotter.Usage(ctx, info.Name) if err != nil { return err @@ -289,7 +290,7 @@ var treeCommand = cli.Command{ tree = make(map[string]*snapshotTreeNode) ) - if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshot.Info) error { + if err := snapshotter.Walk(ctx, func(ctx gocontext.Context, info snapshots.Info) error { // Get or create node and add node details node := getOrCreateTreeNode(info.Name, tree) if info.Parent != "" { @@ -351,7 +352,7 @@ var setLabelCommand = cli.Command{ snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) - info := snapshot.Info{ + info := snapshots.Info{ Name: key, Labels: map[string]string{}, } diff --git a/cmd/ctr/commands/tasks/tasks.go b/cmd/ctr/commands/tasks/tasks.go index 356e3e4fe..6178c8249 100644 --- a/cmd/ctr/commands/tasks/tasks.go +++ b/cmd/ctr/commands/tasks/tasks.go @@ -14,7 +14,7 @@ type resizer interface { var Command = cli.Command{ Name: "tasks", Usage: "manage tasks", - Aliases: []string{"t"}, + Aliases: []string{"t", "task"}, Subcommands: []cli.Command{ attachCommand, checkpointCommand, diff --git a/cmd/ctr/main.go b/cmd/ctr/main.go index e8b2b23ba..f0e63b84c 100644 --- a/cmd/ctr/main.go +++ b/cmd/ctr/main.go @@ -14,7 +14,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands/plugins" "github.com/containerd/containerd/cmd/ctr/commands/pprof" "github.com/containerd/containerd/cmd/ctr/commands/run" - "github.com/containerd/containerd/cmd/ctr/commands/snapshot" + "github.com/containerd/containerd/cmd/ctr/commands/snapshots" "github.com/containerd/containerd/cmd/ctr/commands/tasks" versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version" "github.com/containerd/containerd/defaults" @@ -84,7 +84,7 @@ containerd CLI namespacesCmd.Command, pprof.Command, run.Command, - snapshot.Command, + snapshots.Command, tasks.Command, }, extraCmds...) app.Before = func(context *cli.Context) error { diff --git a/image.go b/image.go index 53b5e2486..202fc42bd 100644 --- a/image.go +++ b/image.go @@ -9,7 +9,7 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/rootfs" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" digest "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -112,7 +112,7 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error { "containerd.io/uncompressed": layer.Diff.Digest.String(), } - unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshot.WithLabels(labels)) + unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshots.WithLabels(labels)) if err != nil { return err } diff --git a/metadata/db.go b/metadata/db.go index 0bbc0c1ef..174432180 100644 --- a/metadata/db.go +++ b/metadata/db.go @@ -11,7 +11,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/gc" "github.com/containerd/containerd/log" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) @@ -60,7 +60,7 @@ type DB struct { // NewDB creates a new metadata database using the provided // bolt database, content store, and snapshotters. -func NewDB(db *bolt.DB, cs content.Store, ss map[string]snapshot.Snapshotter) *DB { +func NewDB(db *bolt.DB, cs content.Store, ss map[string]snapshots.Snapshotter) *DB { m := &DB{ db: db, ss: make(map[string]*snapshotter, len(ss)), @@ -171,7 +171,7 @@ func (m *DB) ContentStore() content.Store { // Snapshotter returns a namespaced content store for // the requested snapshotter name proxied to a snapshotter. -func (m *DB) Snapshotter(name string) snapshot.Snapshotter { +func (m *DB) Snapshotter(name string) snapshots.Snapshotter { sn, ok := m.ss[name] if !ok { return nil diff --git a/metadata/db_test.go b/metadata/db_test.go index 5dd721ec2..bc97e6244 100644 --- a/metadata/db_test.go +++ b/metadata/db_test.go @@ -21,8 +21,8 @@ import ( "github.com/containerd/containerd/gc" "github.com/containerd/containerd/images" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/naive" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/naive" "github.com/gogo/protobuf/types" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -377,7 +377,7 @@ type object struct { labels map[string]string } -func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter) (*gc.Node, error) { +func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshots.Snapshotter) (*gc.Node, error) { var ( node *gc.Node namespace = "test" @@ -408,7 +408,7 @@ func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter) case testSnapshot: ctx := WithTransactionContext(ctx, tx) if v.active { - _, err := sn.Prepare(ctx, v.key, v.parent, snapshot.WithLabels(obj.labels)) + _, err := sn.Prepare(ctx, v.key, v.parent, snapshots.WithLabels(obj.labels)) if err != nil { return nil, err } @@ -418,7 +418,7 @@ func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshot.Snapshotter) if err != nil { return nil, err } - if err := sn.Commit(ctx, v.key, akey, snapshot.WithLabels(obj.labels)); err != nil { + if err := sn.Commit(ctx, v.key, akey, snapshots.WithLabels(obj.labels)); err != nil { return nil, err } } @@ -528,7 +528,7 @@ type testContainer struct { snapshot string } -func newStores(t testing.TB) (*DB, content.Store, snapshot.Snapshotter, func()) { +func newStores(t testing.TB) (*DB, content.Store, snapshots.Snapshotter, func()) { td, err := ioutil.TempDir("", "gc-test-") if err != nil { t.Fatal(err) @@ -548,7 +548,7 @@ func newStores(t testing.TB) (*DB, content.Store, snapshot.Snapshotter, func()) t.Fatal(err) } - mdb := NewDB(db, lcs, map[string]snapshot.Snapshotter{"naive": nsn}) + mdb := NewDB(db, lcs, map[string]snapshots.Snapshotter{"naive": nsn}) return mdb, mdb.ContentStore(), mdb.Snapshotter("naive"), func() { os.RemoveAll(td) diff --git a/metadata/snapshot.go b/metadata/snapshot.go index 235463bbe..3e501c517 100644 --- a/metadata/snapshot.go +++ b/metadata/snapshot.go @@ -14,12 +14,12 @@ import ( "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) type snapshotter struct { - snapshot.Snapshotter + snapshots.Snapshotter name string db *DB l sync.RWMutex @@ -27,7 +27,7 @@ type snapshotter struct { // newSnapshotter returns a new Snapshotter which namespaces the given snapshot // using the provided name and database. -func newSnapshotter(db *DB, name string, sn snapshot.Snapshotter) *snapshotter { +func newSnapshotter(db *DB, name string, sn snapshots.Snapshotter) *snapshotter { return &snapshotter{ Snapshotter: sn, name: name, @@ -75,15 +75,15 @@ func (s *snapshotter) resolveKey(ctx context.Context, key string) (string, error return id, nil } -func (s *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (s *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { ns, err := namespaces.NamespaceRequired(ctx) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } var ( bkey string - local = snapshot.Info{ + local = snapshots.Info{ Name: key, } ) @@ -108,33 +108,33 @@ func (s *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, erro return nil }); err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } info, err := s.Snapshotter.Stat(ctx, bkey) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return overlayInfo(info, local), nil } -func (s *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (s *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { s.l.RLock() defer s.l.RUnlock() ns, err := namespaces.NamespaceRequired(ctx) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } if info.Name == "" { - return snapshot.Info{}, errors.Wrap(errdefs.ErrInvalidArgument, "") + return snapshots.Info{}, errors.Wrap(errdefs.ErrInvalidArgument, "") } var ( bkey string - local = snapshot.Info{ + local = snapshots.Info{ Name: info.Name, } ) @@ -195,18 +195,18 @@ func (s *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths return nil }); err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } info, err = s.Snapshotter.Stat(ctx, bkey) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return overlayInfo(info, local), nil } -func overlayInfo(info, overlay snapshot.Info) snapshot.Info { +func overlayInfo(info, overlay snapshots.Info) snapshots.Info { // Merge info info.Name = overlay.Name info.Created = overlay.Created @@ -222,10 +222,10 @@ func overlayInfo(info, overlay snapshot.Info) snapshot.Info { return info } -func (s *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { +func (s *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { bkey, err := s.resolveKey(ctx, key) if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } return s.Snapshotter.Usage(ctx, bkey) } @@ -238,15 +238,15 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er return s.Snapshotter.Mounts(ctx, bkey) } -func (s *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { +func (s *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { return s.createSnapshot(ctx, key, parent, false, opts) } -func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { +func (s *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { return s.createSnapshot(ctx, key, parent, true, opts) } -func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, readonly bool, opts []snapshot.Opt) ([]mount.Mount, error) { +func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, readonly bool, opts []snapshots.Opt) ([]mount.Mount, error) { s.l.RLock() defer s.l.RUnlock() @@ -255,7 +255,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, re return nil, err } - var base snapshot.Info + var base snapshots.Info for _, opt := range opts { if err := opt(&base); err != nil { return nil, err @@ -336,7 +336,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, re return m, nil } -func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { +func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error { s.l.RLock() defer s.l.RUnlock() @@ -345,7 +345,7 @@ func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap return err } - var base snapshot.Info + var base snapshots.Info for _, opt := range opts { if err := opt(&base); err != nil { return err @@ -493,10 +493,10 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error { type infoPair struct { bkey string - info snapshot.Info + info snapshots.Info } -func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { ns, err := namespaces.NamespaceRequired(ctx) if err != nil { return err @@ -533,7 +533,7 @@ func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho pair := infoPair{ bkey: string(sbkt.Get(bucketKeyName)), - info: snapshot.Info{ + info: snapshots.Info{ Name: string(k), Parent: string(sbkt.Get(bucketKeyParent)), }, @@ -586,7 +586,7 @@ func (s *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho return nil } -func validateSnapshot(info *snapshot.Info) error { +func validateSnapshot(info *snapshots.Info) error { for k, v := range info.Labels { if err := labels.Validate(k, v); err != nil { return errors.Wrapf(err, "info.Labels") @@ -670,7 +670,7 @@ func (s *snapshotter) garbageCollect(ctx context.Context) (d time.Duration, err } type treeNode struct { - info snapshot.Info + info snapshots.Info remove bool children []*treeNode } @@ -679,7 +679,7 @@ func (s *snapshotter) walkTree(ctx context.Context, seen map[string]struct{}) ([ roots := []*treeNode{} nodes := map[string]*treeNode{} - if err := s.Snapshotter.Walk(ctx, func(ctx context.Context, info snapshot.Info) error { + if err := s.Snapshotter.Walk(ctx, func(ctx context.Context, info snapshots.Info) error { _, isSeen := seen[info.Name] node, ok := nodes[info.Name] if !ok { diff --git a/metadata/snapshot_test.go b/metadata/snapshot_test.go index 050063791..a8ab9c74a 100644 --- a/metadata/snapshot_test.go +++ b/metadata/snapshot_test.go @@ -8,13 +8,13 @@ import ( "testing" "github.com/boltdb/bolt" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/naive" - "github.com/containerd/containerd/snapshot/testsuite" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/naive" + "github.com/containerd/containerd/snapshots/testsuite" "github.com/containerd/containerd/testutil" ) -func newTestSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { +func newTestSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { naiveRoot := filepath.Join(root, "naive") if err := os.Mkdir(naiveRoot, 0770); err != nil { return nil, nil, err @@ -29,7 +29,7 @@ func newTestSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, return nil, nil, err } - sn := NewDB(db, nil, map[string]snapshot.Snapshotter{"naive": snapshotter}).Snapshotter("naive") + sn := NewDB(db, nil, map[string]snapshots.Snapshotter{"naive": snapshotter}).Snapshotter("naive") return sn, func() error { if err := sn.Close(); err != nil { diff --git a/oci/client.go b/oci/client.go index 7b7283867..d2cd355c5 100644 --- a/oci/client.go +++ b/oci/client.go @@ -4,13 +4,13 @@ import ( "context" "github.com/containerd/containerd/content" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // Client interface used by SpecOpt type Client interface { - SnapshotService(snapshotterName string) snapshot.Snapshotter + SnapshotService(snapshotterName string) snapshots.Snapshotter } // Image interface used by some SpecOpt to query image configuration diff --git a/rootfs/apply.go b/rootfs/apply.go index a198c99f9..e6d2be6a7 100644 --- a/rootfs/apply.go +++ b/rootfs/apply.go @@ -9,7 +9,7 @@ import ( "github.com/containerd/containerd/diff" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -30,7 +30,7 @@ type Layer struct { // The returned result is a chain id digest representing all the applied layers. // Layers are applied in order they are given, making the first layer the // bottom-most layer in the layer chain. -func ApplyLayers(ctx context.Context, layers []Layer, sn snapshot.Snapshotter, a diff.Differ) (digest.Digest, error) { +func ApplyLayers(ctx context.Context, layers []Layer, sn snapshots.Snapshotter, a diff.Differ) (digest.Digest, error) { var chain []digest.Digest for _, layer := range layers { if _, err := ApplyLayer(ctx, layer, chain, sn, a); err != nil { @@ -46,7 +46,7 @@ func ApplyLayers(ctx context.Context, layers []Layer, sn snapshot.Snapshotter, a // ApplyLayer applies a single layer on top of the given provided layer chain, // using the provided snapshotter and applier. If the layer was unpacked true // is returned, if the layer already exists false is returned. -func ApplyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshot.Snapshotter, a diff.Differ, opts ...snapshot.Opt) (bool, error) { +func ApplyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Differ, opts ...snapshots.Opt) (bool, error) { var ( parent = identity.ChainID(chain) chainID = identity.ChainID(append(chain, layer.Diff.Digest)) diff --git a/rootfs/diff.go b/rootfs/diff.go index 035eb3026..bab7a3cca 100644 --- a/rootfs/diff.go +++ b/rootfs/diff.go @@ -5,7 +5,7 @@ import ( "github.com/containerd/containerd/diff" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/net/context" ) @@ -14,7 +14,7 @@ import ( // of the snapshot. A content ref is provided to track the progress of the // content creation and the provided snapshotter and mount differ are used // for calculating the diff. The descriptor for the layer diff is returned. -func Diff(ctx context.Context, snapshotID string, sn snapshot.Snapshotter, d diff.Differ, opts ...diff.Opt) (ocispec.Descriptor, error) { +func Diff(ctx context.Context, snapshotID string, sn snapshots.Snapshotter, d diff.Differ, opts ...diff.Opt) (ocispec.Descriptor, error) { info, err := sn.Stat(ctx, snapshotID) if err != nil { return ocispec.Descriptor{}, err @@ -28,7 +28,7 @@ func Diff(ctx context.Context, snapshotID string, sn snapshot.Snapshotter, d dif defer sn.Remove(ctx, lowerKey) var upper []mount.Mount - if info.Kind == snapshot.KindActive { + if info.Kind == snapshots.KindActive { upper, err = sn.Mounts(ctx, snapshotID) if err != nil { return ocispec.Descriptor{}, err diff --git a/rootfs/init.go b/rootfs/init.go index 23a9bc4bf..4f32f11ae 100644 --- a/rootfs/init.go +++ b/rootfs/init.go @@ -8,7 +8,7 @@ import ( "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" digest "github.com/opencontainers/go-digest" "github.com/pkg/errors" ) @@ -26,7 +26,7 @@ type Mounter interface { } // InitRootFS initializes the snapshot for use as a rootfs -func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly bool, snapshotter snapshot.Snapshotter, mounter Mounter) ([]mount.Mount, error) { +func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly bool, snapshotter snapshots.Snapshotter, mounter Mounter) ([]mount.Mount, error) { _, err := snapshotter.Stat(ctx, name) if err == nil { return nil, errors.Errorf("rootfs already exists") @@ -51,7 +51,7 @@ func InitRootFS(ctx context.Context, name string, parent digest.Digest, readonly return snapshotter.Prepare(ctx, name, parentS) } -func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshot.Snapshotter, mounter Mounter) (string, error) { +func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshots.Snapshotter, mounter Mounter) (string, error) { initS := fmt.Sprintf("%s %s", parent, initName) if _, err := snapshotter.Stat(ctx, initS); err == nil { return initS, nil diff --git a/server/server.go b/server/server.go index a4c0ca227..6af6df073 100644 --- a/server/server.go +++ b/server/server.go @@ -18,7 +18,7 @@ import ( introspection "github.com/containerd/containerd/api/services/introspection/v1" leasesapi "github.com/containerd/containerd/api/services/leases/v1" namespaces "github.com/containerd/containerd/api/services/namespaces/v1" - snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" + snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" tasks "github.com/containerd/containerd/api/services/tasks/v1" version "github.com/containerd/containerd/api/services/version/v1" "github.com/containerd/containerd/content" @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/log" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" metrics "github.com/docker/go-metrics" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/pkg/errors" @@ -199,7 +199,7 @@ func loadPlugins(config *Config) ([]*plugin.Registration, error) { return nil, err } - snapshotters := make(map[string]snapshot.Snapshotter) + snapshotters := make(map[string]snapshots.Snapshotter) for name, sn := range snapshottersRaw { sn, err := sn.Instance() if err != nil { @@ -207,7 +207,7 @@ func loadPlugins(config *Config) ([]*plugin.Registration, error) { Warnf("could not use snapshotter %v in metadata plugin", name) continue } - snapshotters[name] = sn.(snapshot.Snapshotter) + snapshotters[name] = sn.(snapshots.Snapshotter) } path := filepath.Join(ic.Root, "meta.db") @@ -249,7 +249,7 @@ func interceptor( // No need to change the context case version.VersionServer: ctx = log.WithModule(ctx, "version") - case snapshotapi.SnapshotsServer: + case snapshotsapi.SnapshotsServer: ctx = log.WithModule(ctx, "snapshot") case diff.DiffServer: ctx = log.WithModule(ctx, "diff") diff --git a/services/snapshot/service.go b/services/snapshots/service.go similarity index 66% rename from services/snapshot/service.go rename to services/snapshots/service.go index 3e08d60c5..a5e2b8022 100644 --- a/services/snapshot/service.go +++ b/services/snapshots/service.go @@ -1,10 +1,10 @@ -package snapshot +package snapshots import ( gocontext "context" eventstypes "github.com/containerd/containerd/api/events" - snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" + snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" @@ -12,7 +12,7 @@ import ( "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" ptypes "github.com/gogo/protobuf/types" "golang.org/x/net/context" "google.golang.org/grpc" @@ -48,7 +48,7 @@ func newService(ic *plugin.InitContext) (interface{}, error) { }, nil } -func (s *service) getSnapshotter(name string) (snapshot.Snapshotter, error) { +func (s *service) getSnapshotter(name string) (snapshots.Snapshotter, error) { if name == "" { return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, "snapshotter argument missing") } @@ -61,20 +61,20 @@ func (s *service) getSnapshotter(name string) (snapshot.Snapshotter, error) { } func (s *service) Register(gs *grpc.Server) error { - snapshotapi.RegisterSnapshotsServer(gs, s) + snapshotsapi.RegisterSnapshotsServer(gs, s) return nil } -func (s *service) Prepare(ctx context.Context, pr *snapshotapi.PrepareSnapshotRequest) (*snapshotapi.PrepareSnapshotResponse, error) { +func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotRequest) (*snapshotsapi.PrepareSnapshotResponse, error) { log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot") sn, err := s.getSnapshotter(pr.Snapshotter) if err != nil { return nil, err } - var opts []snapshot.Opt + var opts []snapshots.Opt if pr.Labels != nil { - opts = append(opts, snapshot.WithLabels(pr.Labels)) + opts = append(opts, snapshots.WithLabels(pr.Labels)) } mounts, err := sn.Prepare(ctx, pr.Key, pr.Parent, opts...) if err != nil { @@ -87,31 +87,31 @@ func (s *service) Prepare(ctx context.Context, pr *snapshotapi.PrepareSnapshotRe }); err != nil { return nil, err } - return &snapshotapi.PrepareSnapshotResponse{ + return &snapshotsapi.PrepareSnapshotResponse{ Mounts: fromMounts(mounts), }, nil } -func (s *service) View(ctx context.Context, pr *snapshotapi.ViewSnapshotRequest) (*snapshotapi.ViewSnapshotResponse, error) { +func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest) (*snapshotsapi.ViewSnapshotResponse, error) { log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot") sn, err := s.getSnapshotter(pr.Snapshotter) if err != nil { return nil, err } - var opts []snapshot.Opt + var opts []snapshots.Opt if pr.Labels != nil { - opts = append(opts, snapshot.WithLabels(pr.Labels)) + opts = append(opts, snapshots.WithLabels(pr.Labels)) } mounts, err := sn.View(ctx, pr.Key, pr.Parent, opts...) if err != nil { return nil, errdefs.ToGRPC(err) } - return &snapshotapi.ViewSnapshotResponse{ + return &snapshotsapi.ViewSnapshotResponse{ Mounts: fromMounts(mounts), }, nil } -func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*snapshotapi.MountsResponse, error) { +func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*snapshotsapi.MountsResponse, error) { log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts") sn, err := s.getSnapshotter(mr.Snapshotter) if err != nil { @@ -122,21 +122,21 @@ func (s *service) Mounts(ctx context.Context, mr *snapshotapi.MountsRequest) (*s if err != nil { return nil, errdefs.ToGRPC(err) } - return &snapshotapi.MountsResponse{ + return &snapshotsapi.MountsResponse{ Mounts: fromMounts(mounts), }, nil } -func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequest) (*ptypes.Empty, error) { +func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotRequest) (*ptypes.Empty, error) { log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot") sn, err := s.getSnapshotter(cr.Snapshotter) if err != nil { return nil, err } - var opts []snapshot.Opt + var opts []snapshots.Opt if cr.Labels != nil { - opts = append(opts, snapshot.WithLabels(cr.Labels)) + opts = append(opts, snapshots.WithLabels(cr.Labels)) } if err := sn.Commit(ctx, cr.Name, cr.Key, opts...); err != nil { return nil, errdefs.ToGRPC(err) @@ -151,7 +151,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotapi.CommitSnapshotRequ return empty, nil } -func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequest) (*ptypes.Empty, error) { +func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotRequest) (*ptypes.Empty, error) { log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot") sn, err := s.getSnapshotter(rr.Snapshotter) if err != nil { @@ -170,7 +170,7 @@ func (s *service) Remove(ctx context.Context, rr *snapshotapi.RemoveSnapshotRequ return empty, nil } -func (s *service) Stat(ctx context.Context, sr *snapshotapi.StatSnapshotRequest) (*snapshotapi.StatSnapshotResponse, error) { +func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest) (*snapshotsapi.StatSnapshotResponse, error) { log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot") sn, err := s.getSnapshotter(sr.Snapshotter) if err != nil { @@ -182,10 +182,10 @@ func (s *service) Stat(ctx context.Context, sr *snapshotapi.StatSnapshotRequest) return nil, errdefs.ToGRPC(err) } - return &snapshotapi.StatSnapshotResponse{Info: fromInfo(info)}, nil + return &snapshotsapi.StatSnapshotResponse{Info: fromInfo(info)}, nil } -func (s *service) Update(ctx context.Context, sr *snapshotapi.UpdateSnapshotRequest) (*snapshotapi.UpdateSnapshotResponse, error) { +func (s *service) Update(ctx context.Context, sr *snapshotsapi.UpdateSnapshotRequest) (*snapshotsapi.UpdateSnapshotResponse, error) { log.G(ctx).WithField("key", sr.Info.Name).Debugf("Updating snapshot") sn, err := s.getSnapshotter(sr.Snapshotter) if err != nil { @@ -197,24 +197,24 @@ func (s *service) Update(ctx context.Context, sr *snapshotapi.UpdateSnapshotRequ return nil, errdefs.ToGRPC(err) } - return &snapshotapi.UpdateSnapshotResponse{Info: fromInfo(info)}, nil + return &snapshotsapi.UpdateSnapshotResponse{Info: fromInfo(info)}, nil } -func (s *service) List(sr *snapshotapi.ListSnapshotsRequest, ss snapshotapi.Snapshots_ListServer) error { +func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Snapshots_ListServer) error { sn, err := s.getSnapshotter(sr.Snapshotter) if err != nil { return err } var ( - buffer []snapshotapi.Info - sendBlock = func(block []snapshotapi.Info) error { - return ss.Send(&snapshotapi.ListSnapshotsResponse{ + buffer []snapshotsapi.Info + sendBlock = func(block []snapshotsapi.Info) error { + return ss.Send(&snapshotsapi.ListSnapshotsResponse{ Info: block, }) } ) - err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshot.Info) error { + err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshots.Info) error { buffer = append(buffer, fromInfo(info)) if len(buffer) >= 100 { @@ -240,7 +240,7 @@ func (s *service) List(sr *snapshotapi.ListSnapshotsRequest, ss snapshotapi.Snap return nil } -func (s *service) Usage(ctx context.Context, ur *snapshotapi.UsageRequest) (*snapshotapi.UsageResponse, error) { +func (s *service) Usage(ctx context.Context, ur *snapshotsapi.UsageRequest) (*snapshotsapi.UsageResponse, error) { sn, err := s.getSnapshotter(ur.Snapshotter) if err != nil { return nil, err @@ -254,18 +254,18 @@ func (s *service) Usage(ctx context.Context, ur *snapshotapi.UsageRequest) (*sna return fromUsage(usage), nil } -func fromKind(kind snapshot.Kind) snapshotapi.Kind { - if kind == snapshot.KindActive { - return snapshotapi.KindActive +func fromKind(kind snapshots.Kind) snapshotsapi.Kind { + if kind == snapshots.KindActive { + return snapshotsapi.KindActive } - if kind == snapshot.KindView { - return snapshotapi.KindView + if kind == snapshots.KindView { + return snapshotsapi.KindView } - return snapshotapi.KindCommitted + return snapshotsapi.KindCommitted } -func fromInfo(info snapshot.Info) snapshotapi.Info { - return snapshotapi.Info{ +func fromInfo(info snapshots.Info) snapshotsapi.Info { + return snapshotsapi.Info{ Name: info.Name, Parent: info.Parent, Kind: fromKind(info.Kind), @@ -275,8 +275,8 @@ func fromInfo(info snapshot.Info) snapshotapi.Info { } } -func fromUsage(usage snapshot.Usage) *snapshotapi.UsageResponse { - return &snapshotapi.UsageResponse{ +func fromUsage(usage snapshots.Usage) *snapshotsapi.UsageResponse { + return &snapshotsapi.UsageResponse{ Inodes: usage.Inodes, Size_: usage.Size, } @@ -294,8 +294,8 @@ func fromMounts(mounts []mount.Mount) []*types.Mount { return out } -func toInfo(info snapshotapi.Info) snapshot.Info { - return snapshot.Info{ +func toInfo(info snapshotsapi.Info) snapshots.Info { + return snapshots.Info{ Name: info.Name, Parent: info.Parent, Kind: toKind(info.Kind), @@ -305,12 +305,12 @@ func toInfo(info snapshotapi.Info) snapshot.Info { } } -func toKind(kind snapshotapi.Kind) snapshot.Kind { - if kind == snapshotapi.KindActive { - return snapshot.KindActive +func toKind(kind snapshotsapi.Kind) snapshots.Kind { + if kind == snapshotsapi.KindActive { + return snapshots.KindActive } - if kind == snapshotapi.KindView { - return snapshot.KindView + if kind == snapshotsapi.KindView { + return snapshots.KindView } - return snapshot.KindCommitted + return snapshots.KindCommitted } diff --git a/snapshot.go b/snapshot.go index e29d21ca3..85bdba1b6 100644 --- a/snapshot.go +++ b/snapshot.go @@ -4,17 +4,17 @@ import ( "context" "io" - snapshotapi "github.com/containerd/containerd/api/services/snapshot/v1" + snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" protobuftypes "github.com/gogo/protobuf/types" ) // NewSnapshotterFromClient returns a new Snapshotter which communicates // over a GRPC connection. -func NewSnapshotterFromClient(client snapshotapi.SnapshotsClient, snapshotterName string) snapshot.Snapshotter { +func NewSnapshotterFromClient(client snapshotsapi.SnapshotsClient, snapshotterName string) snapshots.Snapshotter { return &remoteSnapshotter{ client: client, snapshotterName: snapshotterName, @@ -22,25 +22,25 @@ func NewSnapshotterFromClient(client snapshotapi.SnapshotsClient, snapshotterNam } type remoteSnapshotter struct { - client snapshotapi.SnapshotsClient + client snapshotsapi.SnapshotsClient snapshotterName string } -func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (r *remoteSnapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { resp, err := r.client.Stat(ctx, - &snapshotapi.StatSnapshotRequest{ + &snapshotsapi.StatSnapshotRequest{ Snapshotter: r.snapshotterName, Key: key, }) if err != nil { - return snapshot.Info{}, errdefs.FromGRPC(err) + return snapshots.Info{}, errdefs.FromGRPC(err) } return toInfo(resp.Info), nil } -func (r *remoteSnapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (r *remoteSnapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { resp, err := r.client.Update(ctx, - &snapshotapi.UpdateSnapshotRequest{ + &snapshotsapi.UpdateSnapshotRequest{ Snapshotter: r.snapshotterName, Info: fromInfo(info), UpdateMask: &protobuftypes.FieldMask{ @@ -48,24 +48,24 @@ func (r *remoteSnapshotter) Update(ctx context.Context, info snapshot.Info, fiel }, }) if err != nil { - return snapshot.Info{}, errdefs.FromGRPC(err) + return snapshots.Info{}, errdefs.FromGRPC(err) } return toInfo(resp.Info), nil } -func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { - resp, err := r.client.Usage(ctx, &snapshotapi.UsageRequest{ +func (r *remoteSnapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { + resp, err := r.client.Usage(ctx, &snapshotsapi.UsageRequest{ Snapshotter: r.snapshotterName, Key: key, }) if err != nil { - return snapshot.Usage{}, errdefs.FromGRPC(err) + return snapshots.Usage{}, errdefs.FromGRPC(err) } return toUsage(resp), nil } func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) { - resp, err := r.client.Mounts(ctx, &snapshotapi.MountsRequest{ + resp, err := r.client.Mounts(ctx, &snapshotsapi.MountsRequest{ Snapshotter: r.snapshotterName, Key: key, }) @@ -75,14 +75,14 @@ func (r *remoteSnapshotter) Mounts(ctx context.Context, key string) ([]mount.Mou return toMounts(resp.Mounts), nil } -func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - var local snapshot.Info +func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + var local snapshots.Info for _, opt := range opts { if err := opt(&local); err != nil { return nil, err } } - resp, err := r.client.Prepare(ctx, &snapshotapi.PrepareSnapshotRequest{ + resp, err := r.client.Prepare(ctx, &snapshotsapi.PrepareSnapshotRequest{ Snapshotter: r.snapshotterName, Key: key, Parent: parent, @@ -94,14 +94,14 @@ func (r *remoteSnapshotter) Prepare(ctx context.Context, key, parent string, opt return toMounts(resp.Mounts), nil } -func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - var local snapshot.Info +func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + var local snapshots.Info for _, opt := range opts { if err := opt(&local); err != nil { return nil, err } } - resp, err := r.client.View(ctx, &snapshotapi.ViewSnapshotRequest{ + resp, err := r.client.View(ctx, &snapshotsapi.ViewSnapshotRequest{ Snapshotter: r.snapshotterName, Key: key, Parent: parent, @@ -113,14 +113,14 @@ func (r *remoteSnapshotter) View(ctx context.Context, key, parent string, opts . return toMounts(resp.Mounts), nil } -func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { - var local snapshot.Info +func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error { + var local snapshots.Info for _, opt := range opts { if err := opt(&local); err != nil { return err } } - _, err := r.client.Commit(ctx, &snapshotapi.CommitSnapshotRequest{ + _, err := r.client.Commit(ctx, &snapshotsapi.CommitSnapshotRequest{ Snapshotter: r.snapshotterName, Name: name, Key: key, @@ -130,15 +130,15 @@ func (r *remoteSnapshotter) Commit(ctx context.Context, name, key string, opts . } func (r *remoteSnapshotter) Remove(ctx context.Context, key string) error { - _, err := r.client.Remove(ctx, &snapshotapi.RemoveSnapshotRequest{ + _, err := r.client.Remove(ctx, &snapshotsapi.RemoveSnapshotRequest{ Snapshotter: r.snapshotterName, Key: key, }) return errdefs.FromGRPC(err) } -func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { - sc, err := r.client.List(ctx, &snapshotapi.ListSnapshotsRequest{ +func (r *remoteSnapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { + sc, err := r.client.List(ctx, &snapshotsapi.ListSnapshotsRequest{ Snapshotter: r.snapshotterName, }) if err != nil { @@ -167,18 +167,18 @@ func (r *remoteSnapshotter) Close() error { return nil } -func toKind(kind snapshotapi.Kind) snapshot.Kind { - if kind == snapshotapi.KindActive { - return snapshot.KindActive +func toKind(kind snapshotsapi.Kind) snapshots.Kind { + if kind == snapshotsapi.KindActive { + return snapshots.KindActive } - if kind == snapshotapi.KindView { - return snapshot.KindView + if kind == snapshotsapi.KindView { + return snapshots.KindView } - return snapshot.KindCommitted + return snapshots.KindCommitted } -func toInfo(info snapshotapi.Info) snapshot.Info { - return snapshot.Info{ +func toInfo(info snapshotsapi.Info) snapshots.Info { + return snapshots.Info{ Name: info.Name, Parent: info.Parent, Kind: toKind(info.Kind), @@ -188,8 +188,8 @@ func toInfo(info snapshotapi.Info) snapshot.Info { } } -func toUsage(resp *snapshotapi.UsageResponse) snapshot.Usage { - return snapshot.Usage{ +func toUsage(resp *snapshotsapi.UsageResponse) snapshots.Usage { + return snapshots.Usage{ Inodes: resp.Inodes, Size: resp.Size_, } @@ -207,18 +207,18 @@ func toMounts(mm []*types.Mount) []mount.Mount { return mounts } -func fromKind(kind snapshot.Kind) snapshotapi.Kind { - if kind == snapshot.KindActive { - return snapshotapi.KindActive +func fromKind(kind snapshots.Kind) snapshotsapi.Kind { + if kind == snapshots.KindActive { + return snapshotsapi.KindActive } - if kind == snapshot.KindView { - return snapshotapi.KindView + if kind == snapshots.KindView { + return snapshotsapi.KindView } - return snapshotapi.KindCommitted + return snapshotsapi.KindCommitted } -func fromInfo(info snapshot.Info) snapshotapi.Info { - return snapshotapi.Info{ +func fromInfo(info snapshots.Info) snapshotsapi.Info { + return snapshotsapi.Info{ Name: info.Name, Parent: info.Parent, Kind: fromKind(info.Kind), diff --git a/snapshot_test.go b/snapshot_test.go index a345429a3..ae5af388f 100644 --- a/snapshot_test.go +++ b/snapshot_test.go @@ -5,11 +5,11 @@ import ( "runtime" "testing" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/testsuite" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/testsuite" ) -func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { +func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { client, err := New(address) if err != nil { return nil, nil, err diff --git a/snapshot/btrfs/btrfs.go b/snapshots/btrfs/btrfs.go similarity index 88% rename from snapshot/btrfs/btrfs.go rename to snapshots/btrfs/btrfs.go index ddaeae482..be18227b6 100644 --- a/snapshot/btrfs/btrfs.go +++ b/snapshots/btrfs/btrfs.go @@ -14,8 +14,8 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/storage" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/storage" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -43,7 +43,7 @@ type snapshotter struct { // root directory for snapshots and stores the metadata in // a file in the provided root. // root needs to be a mount point of btrfs. -func NewSnapshotter(root string) (snapshot.Snapshotter, error) { +func NewSnapshotter(root string) (snapshots.Snapshotter, error) { // If directory does not exist, create it if _, err := os.Stat(root); err != nil { if !os.IsNotExist(err) { @@ -93,41 +93,41 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) { // // Should be used for parent resolution, existence checks and to discern // the kind of snapshot. -func (b *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (b *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { ctx, t, err := b.ms.TransactionContext(ctx, false) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } defer t.Rollback() _, info, _, err := storage.GetInfo(ctx, key) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil } -func (b *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (b *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { ctx, t, err := b.ms.TransactionContext(ctx, true) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } info, err = storage.UpdateInfo(ctx, info, fieldpaths...) if err != nil { t.Rollback() - return snapshot.Info{}, err + return snapshots.Info{}, err } if err := t.Commit(); err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil } // Usage retrieves the disk usage of the top-level snapshot. -func (b *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { +func (b *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { panic("not implemented") // TODO(stevvooe): Btrfs has a quota model where data can be exclusive to a @@ -143,7 +143,7 @@ func (b *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, er } // Walk the committed snapshots. -func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { ctx, t, err := b.ms.TransactionContext(ctx, false) if err != nil { return err @@ -152,15 +152,15 @@ func (b *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho return storage.WalkInfo(ctx, fn) } -func (b *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return b.makeSnapshot(ctx, snapshot.KindActive, key, parent, opts) +func (b *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return b.makeSnapshot(ctx, snapshots.KindActive, key, parent, opts) } -func (b *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return b.makeSnapshot(ctx, snapshot.KindView, key, parent, opts) +func (b *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return b.makeSnapshot(ctx, snapshots.KindView, key, parent, opts) } -func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { +func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) { ctx, t, err := b.ms.TransactionContext(ctx, true) if err != nil { return nil, err @@ -190,7 +190,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshot.Kind, key, parentp := filepath.Join(b.root, "snapshots", s.ParentIDs[0]) var readonly bool - if kind == snapshot.KindView { + if kind == snapshots.KindView { readonly = true } @@ -222,7 +222,7 @@ func (b *snapshotter) mounts(dir string, s storage.Snapshot) ([]mount.Mount, err options = append(options, fmt.Sprintf("subvolid=%d", sid)) - if s.Kind != snapshot.KindActive { + if s.Kind != snapshots.KindActive { options = append(options, "ro") } @@ -237,7 +237,7 @@ func (b *snapshotter) mounts(dir string, s storage.Snapshot) ([]mount.Mount, err }, nil } -func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) (err error) { +func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) (err error) { ctx, t, err := b.ms.TransactionContext(ctx, true) if err != nil { return err @@ -250,7 +250,7 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap } }() - id, err := storage.CommitActive(ctx, key, name, snapshot.Usage{}, opts...) // TODO(stevvooe): Resolve a usage value for btrfs + id, err := storage.CommitActive(ctx, key, name, snapshots.Usage{}, opts...) // TODO(stevvooe): Resolve a usage value for btrfs if err != nil { return errors.Wrap(err, "failed to commit") } @@ -330,14 +330,14 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) { } switch k { - case snapshot.KindView: + case snapshots.KindView: source = filepath.Join(b.root, "view", id) removed = filepath.Join(b.root, "view", "rm-"+id) readonly = true - case snapshot.KindActive: + case snapshots.KindActive: source = filepath.Join(b.root, "active", id) removed = filepath.Join(b.root, "active", "rm-"+id) - case snapshot.KindCommitted: + case snapshots.KindCommitted: source = filepath.Join(b.root, "snapshots", id) removed = filepath.Join(b.root, "snapshots", "rm-"+id) readonly = true diff --git a/snapshot/btrfs/btrfs_test.go b/snapshots/btrfs/btrfs_test.go similarity index 93% rename from snapshot/btrfs/btrfs_test.go rename to snapshots/btrfs/btrfs_test.go index 97a053ce3..6d3b44238 100644 --- a/snapshot/btrfs/btrfs_test.go +++ b/snapshots/btrfs/btrfs_test.go @@ -12,14 +12,14 @@ import ( "testing" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/testsuite" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/testsuite" "github.com/containerd/containerd/testutil" "github.com/pkg/errors" "golang.org/x/sys/unix" ) -func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshot.Snapshotter, func() error, error) { +func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snapshotter, func() error, error) { mkbtrfs, err := exec.LookPath("mkfs.btrfs") if err != nil { t.Skipf("could not find mkfs.btrfs: %v", err) @@ -27,7 +27,7 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshot.Snaps // TODO: Check for btrfs in /proc/module and skip if not loaded - return func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { + return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { deviceName, cleanupDevice, err := testutil.NewLoopback(100 << 20) // 100 MB if err != nil { diff --git a/snapshot/naive/naive.go b/snapshots/naive/naive.go similarity index 84% rename from snapshot/naive/naive.go rename to snapshots/naive/naive.go index bcd4c35fd..e79e73050 100644 --- a/snapshot/naive/naive.go +++ b/snapshots/naive/naive.go @@ -11,8 +11,8 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/storage" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/storage" "github.com/pkg/errors" ) @@ -34,7 +34,7 @@ type snapshotter struct { // NewSnapshotter returns a Snapshotter which copies layers on the underlying // file system. A metadata file is stored under the root. -func NewSnapshotter(root string) (snapshot.Snapshotter, error) { +func NewSnapshotter(root string) (snapshots.Snapshotter, error) { if err := os.MkdirAll(root, 0700); err != nil { return nil, err } @@ -58,68 +58,68 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) { // // Should be used for parent resolution, existence checks and to discern // the kind of snapshot. -func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } defer t.Rollback() _, info, _, err := storage.GetInfo(ctx, key) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil } -func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { ctx, t, err := o.ms.TransactionContext(ctx, true) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } info, err = storage.UpdateInfo(ctx, info, fieldpaths...) if err != nil { t.Rollback() - return snapshot.Info{}, err + return snapshots.Info{}, err } if err := t.Commit(); err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil } -func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { +func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } defer t.Rollback() id, info, usage, err := storage.GetInfo(ctx, key) if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } - if info.Kind == snapshot.KindActive { + if info.Kind == snapshots.KindActive { du, err := fs.DiskUsage(o.getSnapshotDir(id)) if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } - usage = snapshot.Usage(du) + usage = snapshots.Usage(du) } return usage, nil } -func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return o.createSnapshot(ctx, snapshot.KindActive, key, parent, opts) +func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return o.createSnapshot(ctx, snapshots.KindActive, key, parent, opts) } -func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return o.createSnapshot(ctx, snapshot.KindView, key, parent, opts) +func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return o.createSnapshot(ctx, snapshots.KindView, key, parent, opts) } // Mounts returns the mounts for the transaction identified by key. Can be @@ -139,7 +139,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er return o.mounts(s), nil } -func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { +func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error { ctx, t, err := o.ms.TransactionContext(ctx, true) if err != nil { return err @@ -155,7 +155,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap return err } - if _, err := storage.CommitActive(ctx, key, name, snapshot.Usage(usage), opts...); err != nil { + if _, err := storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil { if rerr := t.Rollback(); rerr != nil { log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction") } @@ -215,7 +215,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { } // Walk the committed snapshots. -func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { return err @@ -224,13 +224,13 @@ func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho return storage.WalkInfo(ctx, fn) } -func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { +func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) { var ( err error path, td string ) - if kind == snapshot.KindActive || parent == "" { + if kind == snapshots.KindActive || parent == "" { td, err = ioutil.TempDir(filepath.Join(o.root, "snapshots"), "new-") if err != nil { return nil, errors.Wrap(err, "failed to create temp dir") @@ -299,13 +299,13 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount { source string ) - if s.Kind == snapshot.KindView { + if s.Kind == snapshots.KindView { roFlag = "ro" } else { roFlag = "rw" } - if len(s.ParentIDs) == 0 || s.Kind == snapshot.KindActive { + if len(s.ParentIDs) == 0 || s.Kind == snapshots.KindActive { source = o.getSnapshotDir(s.ID) } else { source = o.getSnapshotDir(s.ParentIDs[0]) diff --git a/snapshot/naive/naive_test.go b/snapshots/naive/naive_test.go similarity index 69% rename from snapshot/naive/naive_test.go rename to snapshots/naive/naive_test.go index 0da3e848d..c4d3c84a6 100644 --- a/snapshot/naive/naive_test.go +++ b/snapshots/naive/naive_test.go @@ -5,12 +5,12 @@ import ( "runtime" "testing" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/testsuite" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/testsuite" "github.com/containerd/containerd/testutil" ) -func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { +func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { snapshotter, err := NewSnapshotter(root) if err != nil { return nil, nil, err diff --git a/snapshot/overlay/overlay.go b/snapshots/overlay/overlay.go similarity index 87% rename from snapshot/overlay/overlay.go rename to snapshots/overlay/overlay.go index 33a1edd92..f3de4bcc2 100644 --- a/snapshot/overlay/overlay.go +++ b/snapshots/overlay/overlay.go @@ -16,8 +16,8 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/storage" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/storage" "github.com/pkg/errors" ) @@ -41,7 +41,7 @@ type snapshotter struct { // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs // diffs are stored under the provided root. A metadata file is stored under // the root. -func NewSnapshotter(root string) (snapshot.Snapshotter, error) { +func NewSnapshotter(root string) (snapshots.Snapshotter, error) { if err := os.MkdirAll(root, 0700); err != nil { return nil, err } @@ -72,34 +72,34 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) { // // Should be used for parent resolution, existence checks and to discern // the kind of snapshot. -func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } defer t.Rollback() _, info, _, err := storage.GetInfo(ctx, key) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil } -func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { ctx, t, err := o.ms.TransactionContext(ctx, true) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } info, err = storage.UpdateInfo(ctx, info, fieldpaths...) if err != nil { t.Rollback() - return snapshot.Info{}, err + return snapshots.Info{}, err } if err := t.Commit(); err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return info, nil @@ -111,39 +111,39 @@ func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths // "upper") directory and may take some time. // // For committed snapshots, the value is returned from the metadata database. -func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { +func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } id, info, usage, err := storage.GetInfo(ctx, key) t.Rollback() // transaction no longer needed at this point. if err != nil { - return snapshot.Usage{}, err + return snapshots.Usage{}, err } upperPath := o.upperPath(id) - if info.Kind == snapshot.KindActive { + if info.Kind == snapshots.KindActive { du, err := fs.DiskUsage(upperPath) if err != nil { // TODO(stevvooe): Consider not reporting an error in this case. - return snapshot.Usage{}, err + return snapshots.Usage{}, err } - usage = snapshot.Usage(du) + usage = snapshots.Usage(du) } return usage, nil } -func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return o.createSnapshot(ctx, snapshot.KindActive, key, parent, opts) +func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return o.createSnapshot(ctx, snapshots.KindActive, key, parent, opts) } -func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { - return o.createSnapshot(ctx, snapshot.KindView, key, parent, opts) +func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { + return o.createSnapshot(ctx, snapshots.KindView, key, parent, opts) } // Mounts returns the mounts for the transaction identified by key. Can be @@ -163,7 +163,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er return o.mounts(s), nil } -func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { +func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error { ctx, t, err := o.ms.TransactionContext(ctx, true) if err != nil { return err @@ -188,7 +188,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap return err } - if _, err = storage.CommitActive(ctx, key, name, snapshot.Usage(usage), opts...); err != nil { + if _, err = storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil { return errors.Wrap(err, "failed to commit snapshot") } return t.Commit() @@ -238,7 +238,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) { } // Walk the committed snapshots. -func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { return err @@ -247,7 +247,7 @@ func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapsho return storage.WalkInfo(ctx, fn) } -func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts []snapshot.Opt) ([]mount.Mount, error) { +func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) { var ( path string snapshotDir = filepath.Join(o.root, "snapshots") @@ -277,7 +277,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshot.Kind, ke return nil, err } - if kind == snapshot.KindActive { + if kind == snapshots.KindActive { if err = os.MkdirAll(filepath.Join(td, "work"), 0711); err != nil { return nil, err } @@ -336,7 +336,7 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount { // if we only have one layer/no parents then just return a bind mount as overlay // will not work roFlag := "rw" - if s.Kind == snapshot.KindView { + if s.Kind == snapshots.KindView { roFlag = "ro" } @@ -353,7 +353,7 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount { } var options []string - if s.Kind == snapshot.KindActive { + if s.Kind == snapshots.KindActive { options = append(options, fmt.Sprintf("workdir=%s", o.workPath(s.ID)), fmt.Sprintf("upperdir=%s", o.upperPath(s.ID)), diff --git a/snapshot/overlay/overlay_test.go b/snapshots/overlay/overlay_test.go similarity index 94% rename from snapshot/overlay/overlay_test.go rename to snapshots/overlay/overlay_test.go index 653a4b038..7083e3212 100644 --- a/snapshot/overlay/overlay_test.go +++ b/snapshots/overlay/overlay_test.go @@ -12,13 +12,13 @@ import ( "testing" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" - "github.com/containerd/containerd/snapshot/storage" - "github.com/containerd/containerd/snapshot/testsuite" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/containerd/snapshots/testsuite" "github.com/containerd/containerd/testutil" ) -func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) { +func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { snapshotter, err := NewSnapshotter(root) if err != nil { return nil, nil, err @@ -150,7 +150,7 @@ func TestOverlayOverlayMount(t *testing.T) { } } -func getBasePath(ctx context.Context, sn snapshot.Snapshotter, root, key string) string { +func getBasePath(ctx context.Context, sn snapshots.Snapshotter, root, key string) string { o := sn.(*snapshotter) ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { @@ -166,7 +166,7 @@ func getBasePath(ctx context.Context, sn snapshot.Snapshotter, root, key string) return filepath.Join(root, "snapshots", s.ID) } -func getParents(ctx context.Context, sn snapshot.Snapshotter, root, key string) []string { +func getParents(ctx context.Context, sn snapshots.Snapshotter, root, key string) []string { o := sn.(*snapshotter) ctx, t, err := o.ms.TransactionContext(ctx, false) if err != nil { diff --git a/snapshot/snapshotter.go b/snapshots/snapshotter.go similarity index 99% rename from snapshot/snapshotter.go rename to snapshots/snapshotter.go index a7a33cc57..cde4c7261 100644 --- a/snapshot/snapshotter.go +++ b/snapshots/snapshotter.go @@ -1,4 +1,4 @@ -package snapshot +package snapshots import ( "context" diff --git a/snapshot/storage/bolt.go b/snapshots/storage/bolt.go similarity index 90% rename from snapshot/storage/bolt.go rename to snapshots/storage/bolt.go index 26c394c06..08e9241c8 100644 --- a/snapshot/storage/bolt.go +++ b/snapshots/storage/bolt.go @@ -10,7 +10,7 @@ import ( "github.com/boltdb/bolt" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/metadata/boltutil" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) @@ -56,11 +56,11 @@ func getParentPrefix(b []byte) uint64 { // GetInfo returns the snapshot Info directly from the metadata. Requires a // context with a storage transaction. -func GetInfo(ctx context.Context, key string) (string, snapshot.Info, snapshot.Usage, error) { +func GetInfo(ctx context.Context, key string) (string, snapshots.Info, snapshots.Usage, error) { var ( id uint64 - su snapshot.Usage - si = snapshot.Info{ + su snapshots.Usage + si = snapshots.Info{ Name: key, } ) @@ -69,15 +69,15 @@ func GetInfo(ctx context.Context, key string) (string, snapshot.Info, snapshot.U return readSnapshot(bkt, &id, &si) }) if err != nil { - return "", snapshot.Info{}, snapshot.Usage{}, err + return "", snapshots.Info{}, snapshots.Usage{}, err } return fmt.Sprintf("%d", id), si, su, nil } // UpdateInfo updates an existing snapshot info's data -func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { - updated := snapshot.Info{ +func UpdateInfo(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { + updated := snapshots.Info{ Name: info.Name, } err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { @@ -120,7 +120,7 @@ func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) ( return boltutil.WriteLabels(sbkt, updated.Labels) }) if err != nil { - return snapshot.Info{}, err + return snapshots.Info{}, err } return updated, nil } @@ -128,7 +128,7 @@ func UpdateInfo(ctx context.Context, info snapshot.Info, fieldpaths ...string) ( // WalkInfo iterates through all metadata Info for the stored snapshots and // calls the provided function for each. Requires a context with a storage // transaction. -func WalkInfo(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func WalkInfo(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { return withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { return bkt.ForEach(func(k, v []byte) error { // skip non buckets @@ -137,7 +137,7 @@ func WalkInfo(ctx context.Context, fn func(context.Context, snapshot.Info) error } var ( sbkt = bkt.Bucket(k) - si = snapshot.Info{ + si = snapshots.Info{ Name: string(k), } ) @@ -162,7 +162,7 @@ func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) { s.ID = fmt.Sprintf("%d", readID(sbkt)) s.Kind = readKind(sbkt) - if s.Kind != snapshot.KindActive && s.Kind != snapshot.KindView { + if s.Kind != snapshots.KindActive && s.Kind != snapshots.KindView { return errors.Wrapf(errdefs.ErrFailedPrecondition, "requested snapshot %v not active or view", key) } @@ -187,13 +187,13 @@ func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) { } // CreateSnapshot inserts a record for an active or view snapshot with the provided parent. -func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, opts ...snapshot.Opt) (s Snapshot, err error) { +func CreateSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts ...snapshots.Opt) (s Snapshot, err error) { switch kind { - case snapshot.KindActive, snapshot.KindView: + case snapshots.KindActive, snapshots.KindView: default: return Snapshot{}, errors.Wrapf(errdefs.ErrInvalidArgument, "snapshot type %v invalid; only snapshots of type Active or View can be created", kind) } - var base snapshot.Info + var base snapshots.Info for _, opt := range opts { if err := opt(&base); err != nil { return Snapshot{}, err @@ -210,7 +210,7 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, return errors.Wrap(errdefs.ErrNotFound, "missing parent bucket") } - if readKind(spbkt) != snapshot.KindCommitted { + if readKind(spbkt) != snapshots.KindCommitted { return errors.Wrap(errdefs.ErrInvalidArgument, "parent is not committed snapshot") } } @@ -228,7 +228,7 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, } t := time.Now().UTC() - si := snapshot.Info{ + si := snapshots.Info{ Parent: parent, Kind: kind, Labels: base.Labels, @@ -268,10 +268,10 @@ func CreateSnapshot(ctx context.Context, kind snapshot.Kind, key, parent string, // Remove removes a snapshot from the metastore. The string identifier for the // snapshot is returned as well as the kind. The provided context must contain a // writable transaction. -func Remove(ctx context.Context, key string) (string, snapshot.Kind, error) { +func Remove(ctx context.Context, key string) (string, snapshots.Kind, error) { var ( id uint64 - si snapshot.Info + si snapshots.Info ) if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error { @@ -320,10 +320,10 @@ func Remove(ctx context.Context, key string) (string, snapshot.Kind, error) { // lookup or removal. The returned string identifier for the committed snapshot // is the same identifier of the original active snapshot. The provided context // must contain a writable transaction. -func CommitActive(ctx context.Context, key, name string, usage snapshot.Usage, opts ...snapshot.Opt) (string, error) { +func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, opts ...snapshots.Opt) (string, error) { var ( id uint64 - base snapshot.Info + base snapshots.Info ) for _, opt := range opts { if err := opt(&base); err != nil { @@ -344,15 +344,15 @@ func CommitActive(ctx context.Context, key, name string, usage snapshot.Usage, o return errors.Wrap(errdefs.ErrNotFound, "failed to get active snapshot") } - var si snapshot.Info + var si snapshots.Info if err := readSnapshot(sbkt, &id, &si); err != nil { return errors.Wrap(err, "failed to read snapshot") } - if si.Kind != snapshot.KindActive { + if si.Kind != snapshots.KindActive { return errors.Wrapf(errdefs.ErrFailedPrecondition, "snapshot %v is not active", name) } - si.Kind = snapshot.KindCommitted + si.Kind = snapshots.KindCommitted si.Created = time.Now().UTC() si.Updated = si.Created @@ -460,10 +460,10 @@ func parents(bkt, pbkt *bolt.Bucket, parent uint64) (parents []string, err error } } -func readKind(bkt *bolt.Bucket) (k snapshot.Kind) { +func readKind(bkt *bolt.Bucket) (k snapshots.Kind) { kind := bkt.Get(bucketKeyKind) if len(kind) == 1 { - k = snapshot.Kind(kind[0]) + k = snapshots.Kind(kind[0]) } return } @@ -473,7 +473,7 @@ func readID(bkt *bolt.Bucket) uint64 { return id } -func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshot.Info) error { +func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshots.Info) error { if id != nil { *id = readID(bkt) } @@ -495,7 +495,7 @@ func readSnapshot(bkt *bolt.Bucket, id *uint64, si *snapshot.Info) error { return nil } -func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshot.Info) error { +func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshots.Info) error { idEncoded, err := encodeID(id) if err != nil { return err @@ -519,12 +519,12 @@ func putSnapshot(bkt *bolt.Bucket, id uint64, si snapshot.Info) error { return boltutil.WriteLabels(bkt, si.Labels) } -func getUsage(bkt *bolt.Bucket, usage *snapshot.Usage) { +func getUsage(bkt *bolt.Bucket, usage *snapshots.Usage) { usage.Inodes, _ = binary.Varint(bkt.Get(bucketKeyInodes)) usage.Size, _ = binary.Varint(bkt.Get(bucketKeySize)) } -func putUsage(bkt *bolt.Bucket, usage snapshot.Usage) error { +func putUsage(bkt *bolt.Bucket, usage snapshots.Usage) error { for _, v := range []struct { key []byte value int64 diff --git a/snapshot/storage/bolt_test.go b/snapshots/storage/bolt_test.go similarity index 100% rename from snapshot/storage/bolt_test.go rename to snapshots/storage/bolt_test.go diff --git a/snapshot/storage/metastore.go b/snapshots/storage/metastore.go similarity index 97% rename from snapshot/storage/metastore.go rename to snapshots/storage/metastore.go index a8d18868c..c6c49f263 100644 --- a/snapshot/storage/metastore.go +++ b/snapshots/storage/metastore.go @@ -10,7 +10,7 @@ import ( "sync" "github.com/boltdb/bolt" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) @@ -35,7 +35,7 @@ type Transactor interface { // the last index. The last index should always be considered the active // snapshots immediate parent. type Snapshot struct { - Kind snapshot.Kind + Kind snapshots.Kind ID string ParentIDs []string } diff --git a/snapshot/storage/metastore_bench_test.go b/snapshots/storage/metastore_bench_test.go similarity index 84% rename from snapshot/storage/metastore_bench_test.go rename to snapshots/storage/metastore_bench_test.go index 18b2fd120..0a6ceac48 100644 --- a/snapshot/storage/metastore_bench_test.go +++ b/snapshots/storage/metastore_bench_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" ) // Benchmarks returns a benchmark suite using the provided metadata store @@ -106,14 +106,14 @@ func openCloseReadonly(b *testing.B, name string, metaFn metaFactory) func(b *te } func createActiveFromBase(ctx context.Context, ms *MetaStore, active, base string) error { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "bottom", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "bottom", ""); err != nil { return err } - if _, err := CommitActive(ctx, "bottom", base, snapshot.Usage{}); err != nil { + if _, err := CommitActive(ctx, "bottom", base, snapshots.Usage{}); err != nil { return err } - _, err := CreateSnapshot(ctx, snapshot.KindActive, active, base) + _, err := CreateSnapshot(ctx, snapshots.KindActive, active, base) return err } @@ -135,7 +135,7 @@ func statCommittedBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { if err := createActiveFromBase(ctx, ms, "active", "base"); err != nil { b.Fatal(err) } - if _, err := CommitActive(ctx, "active", "committed", snapshot.Usage{}); err != nil { + if _, err := CommitActive(ctx, "active", "committed", snapshots.Usage{}); err != nil { b.Fatal(err) } @@ -150,7 +150,7 @@ func statCommittedBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func createActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { for i := 0; i < b.N; i++ { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil { b.Fatal(err) } b.StopTimer() @@ -164,7 +164,7 @@ func createActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func removeBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { for i := 0; i < b.N; i++ { b.StopTimer() - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil { b.Fatal(err) } b.StartTimer() @@ -177,11 +177,11 @@ func removeBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func commitBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { b.StopTimer() for i := 0; i < b.N; i++ { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", ""); err != nil { b.Fatal(err) } b.StartTimer() - if _, err := CommitActive(ctx, "active", "committed", snapshot.Usage{}); err != nil { + if _, err := CommitActive(ctx, "active", "committed", snapshots.Usage{}); err != nil { b.Fatal(err) } b.StopTimer() @@ -194,17 +194,17 @@ func commitBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { func getActiveBenchmark(ctx context.Context, b *testing.B, ms *MetaStore) { var base string for i := 1; i <= 10; i++ { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "tmp", base); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "tmp", base); err != nil { b.Fatalf("create active failed: %+v", err) } base = fmt.Sprintf("base-%d", i) - if _, err := CommitActive(ctx, "tmp", base, snapshot.Usage{}); err != nil { + if _, err := CommitActive(ctx, "tmp", base, snapshots.Usage{}); err != nil { b.Fatalf("commit failed: %+v", err) } } - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active", base); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active", base); err != nil { b.Fatalf("create active failed: %+v", err) } b.ResetTimer() diff --git a/snapshot/storage/metastore_test.go b/snapshots/storage/metastore_test.go similarity index 84% rename from snapshot/storage/metastore_test.go rename to snapshots/storage/metastore_test.go index b34efa743..33c30a1f7 100644 --- a/snapshot/storage/metastore_test.go +++ b/snapshots/storage/metastore_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) @@ -129,71 +129,71 @@ func inWriteTransaction(fn testFunc) testFunc { // - "active-4": readonly active without parent" // - "active-5": readonly active with parent "committed-2" func basePopulate(ctx context.Context, ms *MetaStore) error { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-1", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-1", ""); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshot.Usage{Size: 1}); err != nil { + if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshots.Usage{Size: 1}); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-2", "committed-1"); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-2", "committed-1"); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CommitActive(ctx, "committed-tmp-2", "committed-2", snapshot.Usage{Size: 2}); err != nil { + if _, err := CommitActive(ctx, "committed-tmp-2", "committed-2", snapshots.Usage{Size: 2}); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", ""); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-2", "committed-1"); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-2", "committed-1"); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-3", "committed-2"); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-3", "committed-2"); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", ""); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-2"); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-2"); err != nil { return errors.Wrap(err, "failed to create active") } return nil } -var baseInfo = map[string]snapshot.Info{ +var baseInfo = map[string]snapshots.Info{ "committed-1": { Name: "committed-1", Parent: "", - Kind: snapshot.KindCommitted, + Kind: snapshots.KindCommitted, }, "committed-2": { Name: "committed-2", Parent: "committed-1", - Kind: snapshot.KindCommitted, + Kind: snapshots.KindCommitted, }, "active-1": { Name: "active-1", Parent: "", - Kind: snapshot.KindActive, + Kind: snapshots.KindActive, }, "active-2": { Name: "active-2", Parent: "committed-1", - Kind: snapshot.KindActive, + Kind: snapshots.KindActive, }, "active-3": { Name: "active-3", Parent: "committed-2", - Kind: snapshot.KindActive, + Kind: snapshots.KindActive, }, "view-1": { Name: "view-1", Parent: "", - Kind: snapshot.KindView, + Kind: snapshots.KindView, }, "view-2": { Name: "view-2", Parent: "committed-2", - Kind: snapshot.KindView, + Kind: snapshots.KindView, }, } @@ -252,8 +252,8 @@ func testGetInfoNotExist(ctx context.Context, t *testing.T, ms *MetaStore) { } func testWalk(ctx context.Context, t *testing.T, ms *MetaStore) { - found := map[string]snapshot.Info{} - err := WalkInfo(ctx, func(ctx context.Context, info snapshot.Info) error { + found := map[string]snapshots.Info{} + err := WalkInfo(ctx, func(ctx context.Context, info snapshots.Info) error { if _, ok := found[info.Name]; ok { return errors.Errorf("entry already encountered") } @@ -272,35 +272,35 @@ func testWalk(ctx context.Context, t *testing.T, ms *MetaStore) { func testGetSnapshot(ctx context.Context, t *testing.T, ms *MetaStore) { snapshotMap := map[string]Snapshot{} populate := func(ctx context.Context, ms *MetaStore) error { - if _, err := CreateSnapshot(ctx, snapshot.KindActive, "committed-tmp-1", ""); err != nil { + if _, err := CreateSnapshot(ctx, snapshots.KindActive, "committed-tmp-1", ""); err != nil { return errors.Wrap(err, "failed to create active") } - if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshot.Usage{}); err != nil { + if _, err := CommitActive(ctx, "committed-tmp-1", "committed-1", snapshots.Usage{}); err != nil { return errors.Wrap(err, "failed to create active") } for _, opts := range []struct { - Kind snapshot.Kind + Kind snapshots.Kind Name string Parent string }{ { Name: "active-1", - Kind: snapshot.KindActive, + Kind: snapshots.KindActive, }, { Name: "active-2", Parent: "committed-1", - Kind: snapshot.KindActive, + Kind: snapshots.KindActive, }, { Name: "view-1", - Kind: snapshot.KindView, + Kind: snapshots.KindView, }, { Name: "view-2", Parent: "committed-1", - Kind: snapshot.KindView, + Kind: snapshots.KindView, }, } { active, err := CreateSnapshot(ctx, opts.Kind, opts.Name, opts.Parent) @@ -336,26 +336,26 @@ func testGetSnapshotNotExist(ctx context.Context, t *testing.T, ms *MetaStore) { } func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) { - a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") + a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "") if err != nil { t.Fatal(err) } - if a1.Kind != snapshot.KindActive { + if a1.Kind != snapshots.KindActive { t.Fatal("Expected writable active") } - a2, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", "") + a2, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", "") if err != nil { t.Fatal(err) } if a2.ID == a1.ID { t.Fatal("Returned active identifiers must be unique") } - if a2.Kind != snapshot.KindView { + if a2.Kind != snapshots.KindView { t.Fatal("Expected a view") } - commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) + commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{}) if err != nil { t.Fatal(err) } @@ -363,7 +363,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) { t.Fatal("Snapshot identifier must not change on commit") } - a3, err := CreateSnapshot(ctx, snapshot.KindActive, "active-3", "committed-1") + a3, err := CreateSnapshot(ctx, snapshots.KindActive, "active-3", "committed-1") if err != nil { t.Fatal(err) } @@ -376,11 +376,11 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) { if a3.ParentIDs[0] != commitID { t.Fatal("Expected active parent to be same as commit ID") } - if a3.Kind != snapshot.KindActive { + if a3.Kind != snapshots.KindActive { t.Fatal("Expected writable active") } - a4, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-1") + a4, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-1") if err != nil { t.Fatal(err) } @@ -393,7 +393,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) { if a3.ParentIDs[0] != commitID { t.Fatal("Expected active parent to be same as commit ID") } - if a4.Kind != snapshot.KindView { + if a4.Kind != snapshots.KindView { t.Fatal("Expected a view") } } @@ -402,14 +402,14 @@ func testCreateActiveExist(ctx context.Context, t *testing.T, ms *MetaStore) { if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) } - _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") + _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "") assertExist(t, err) - _, err = CreateSnapshot(ctx, snapshot.KindActive, "committed-1", "") + _, err = CreateSnapshot(ctx, snapshots.KindActive, "committed-1", "") assertExist(t, err) } func testCreateActiveNotExist(ctx context.Context, t *testing.T, ms *MetaStore) { - _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "does-not-exist") + _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "does-not-exist") assertNotExist(t, err) } @@ -417,20 +417,20 @@ func testCreateActiveFromActive(ctx context.Context, t *testing.T, ms *MetaStore if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) } - _, err := CreateSnapshot(ctx, snapshot.KindActive, "active-new", "active-1") + _, err := CreateSnapshot(ctx, snapshots.KindActive, "active-new", "active-1") assertNotCommitted(t, err) } func testCommit(ctx context.Context, t *testing.T, ms *MetaStore) { - a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") + a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "") if err != nil { t.Fatal(err) } - if a1.Kind != snapshot.KindActive { + if a1.Kind != snapshots.KindActive { t.Fatal("Expected writable active") } - commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) + commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{}) if err != nil { t.Fatal(err) } @@ -448,7 +448,7 @@ func testCommitExist(ctx context.Context, t *testing.T, ms *MetaStore) { if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) } - _, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) + _, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{}) assertExist(t, err) } @@ -456,7 +456,7 @@ func testCommitCommitted(ctx context.Context, t *testing.T, ms *MetaStore) { if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) } - _, err := CommitActive(ctx, "committed-1", "committed-3", snapshot.Usage{}) + _, err := CommitActive(ctx, "committed-1", "committed-3", snapshots.Usage{}) assertNotActive(t, err) } @@ -464,19 +464,19 @@ func testCommitViewFails(ctx context.Context, t *testing.T, ms *MetaStore) { if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) } - _, err := CommitActive(ctx, "view-1", "committed-3", snapshot.Usage{}) + _, err := CommitActive(ctx, "view-1", "committed-3", snapshots.Usage{}) if err == nil { t.Fatal("Expected error committing readonly active") } } func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { - a1, err := CreateSnapshot(ctx, snapshot.KindActive, "active-1", "") + a1, err := CreateSnapshot(ctx, snapshots.KindActive, "active-1", "") if err != nil { t.Fatal(err) } - commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshot.Usage{}) + commitID, err := CommitActive(ctx, "active-1", "committed-1", snapshots.Usage{}) if err != nil { t.Fatal(err) } @@ -484,12 +484,12 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { t.Fatal("Snapshot identifier must not change on commit") } - a2, err := CreateSnapshot(ctx, snapshot.KindView, "view-1", "committed-1") + a2, err := CreateSnapshot(ctx, snapshots.KindView, "view-1", "committed-1") if err != nil { t.Fatal(err) } - a3, err := CreateSnapshot(ctx, snapshot.KindView, "view-2", "committed-1") + a3, err := CreateSnapshot(ctx, snapshots.KindView, "view-2", "committed-1") if err != nil { t.Fatal(err) } @@ -504,7 +504,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { if r3 != a3.ID { t.Fatal("Expected remove ID to match create ID") } - if k3 != snapshot.KindView { + if k3 != snapshots.KindView { t.Fatalf("Expected view kind, got %v", k3) } @@ -515,7 +515,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { if r2 != a2.ID { t.Fatal("Expected remove ID to match create ID") } - if k2 != snapshot.KindView { + if k2 != snapshots.KindView { t.Fatalf("Expected view kind, got %v", k2) } @@ -526,7 +526,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) { if r1 != commitID { t.Fatal("Expected remove ID to match commit ID") } - if k1 != snapshot.KindCommitted { + if k1 != snapshots.KindCommitted { t.Fatalf("Expected committed kind, got %v", k1) } } @@ -581,10 +581,10 @@ func testParents(ctx context.Context, t *testing.T, ms *MetaStore) { id string parents []string ) - if info.Kind == snapshot.KindCommitted { + if info.Kind == snapshots.KindCommitted { // When commited, create view and resolve from view nid := fmt.Sprintf("test-%s-%d", tc.Name, i) - s, err := CreateSnapshot(ctx, snapshot.KindView, nid, name) + s, err := CreateSnapshot(ctx, snapshots.KindView, nid, name) if err != nil { t.Fatalf("Failed to get snapshot %s: %v", tc.Name, err) } diff --git a/snapshot/testsuite/helpers.go b/snapshots/testsuite/helpers.go similarity index 89% rename from snapshot/testsuite/helpers.go rename to snapshots/testsuite/helpers.go index 18a0fab73..1a0928b44 100644 --- a/snapshot/testsuite/helpers.go +++ b/snapshots/testsuite/helpers.go @@ -9,7 +9,7 @@ import ( "github.com/containerd/containerd/fs/fstest" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) @@ -34,7 +34,7 @@ func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) { // createSnapshot creates a new snapshot in the snapshotter // given an applier to run on top of the given parent. -func createSnapshot(ctx context.Context, sn snapshot.Snapshotter, parent, work string, a fstest.Applier) (string, error) { +func createSnapshot(ctx context.Context, sn snapshots.Snapshotter, parent, work string, a fstest.Applier) (string, error) { n := fmt.Sprintf("%p-%d", a, rand.Int()) prepare := fmt.Sprintf("%s-prepare", n) @@ -54,7 +54,7 @@ func createSnapshot(ctx context.Context, sn snapshot.Snapshotter, parent, work s return n, nil } -func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, check string) (err error) { +func checkSnapshot(ctx context.Context, sn snapshots.Snapshotter, work, name, check string) (err error) { td, err := ioutil.TempDir(work, "check") if err != nil { return errors.Wrap(err, "failed to create temp dir") @@ -95,7 +95,7 @@ func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, che // checkSnapshots creates a new chain of snapshots in the given snapshotter // using the provided appliers, checking each snapshot created in a view // against the changes applied to a single directory. -func checkSnapshots(ctx context.Context, sn snapshot.Snapshotter, work string, as ...fstest.Applier) error { +func checkSnapshots(ctx context.Context, sn snapshots.Snapshotter, work string, as ...fstest.Applier) error { td, err := ioutil.TempDir(work, "flat") if err != nil { return errors.Wrap(err, "failed to create temp dir") @@ -124,7 +124,7 @@ func checkSnapshots(ctx context.Context, sn snapshot.Snapshotter, work string, a } // checkInfo checks that the infos are the same -func checkInfo(si1, si2 snapshot.Info) error { +func checkInfo(si1, si2 snapshots.Info) error { if si1.Kind != si2.Kind { return errors.Errorf("Expected kind %v, got %v", si1.Kind, si2.Kind) } diff --git a/snapshot/testsuite/helpers_linux.go b/snapshots/testsuite/helpers_linux.go similarity index 100% rename from snapshot/testsuite/helpers_linux.go rename to snapshots/testsuite/helpers_linux.go diff --git a/snapshot/testsuite/helpers_other.go b/snapshots/testsuite/helpers_other.go similarity index 100% rename from snapshot/testsuite/helpers_other.go rename to snapshots/testsuite/helpers_other.go diff --git a/snapshot/testsuite/issues.go b/snapshots/testsuite/issues.go similarity index 93% rename from snapshot/testsuite/issues.go rename to snapshots/testsuite/issues.go index 8aeed2a32..a4e8ec5ad 100644 --- a/snapshot/testsuite/issues.go +++ b/snapshots/testsuite/issues.go @@ -8,7 +8,7 @@ import ( "time" "github.com/containerd/containerd/fs/fstest" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" ) // Checks which cover former issues found in older layering models. @@ -23,7 +23,7 @@ import ( // Cause of issue was originally related to tar, snapshot should be able to // avoid such issues by not relying on tar to create layers. // See https://github.com/docker/docker/issues/21555 -func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateDir("/etc", 0700), fstest.CreateFile("/etc/hosts", []byte("mydomain 10.0.0.1"), 0644), @@ -54,7 +54,7 @@ func checkLayerFileUpdate(ctx context.Context, t *testing.T, sn snapshot.Snapsho // checkRemoveDirectoryInLowerLayer // See https://github.com/docker/docker/issues/25244 -func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateDir("/lib", 0700), fstest.CreateFile("/lib/hidden", []byte{}, 0644), @@ -77,7 +77,7 @@ func checkRemoveDirectoryInLowerLayer(ctx context.Context, t *testing.T, sn snap // See https://github.com/docker/docker/issues/20240 aufs // See https://github.com/docker/docker/issues/24913 overlay // see https://github.com/docker/docker/issues/28391 overlay2 -func checkChown(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkChown(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateDir("/opt", 0700), fstest.CreateDir("/opt/a", 0700), @@ -98,7 +98,7 @@ func checkChown(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work // checkRename // https://github.com/docker/docker/issues/25409 -func checkRename(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkRename(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { t.Skip("rename test still fails on some kernels with overlay") l1Init := fstest.Apply( fstest.CreateDir("/dir1", 0700), @@ -120,7 +120,7 @@ func checkRename(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, wor // checkDirectoryPermissionOnCommit // https://github.com/docker/docker/issues/27298 -func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/dir2", 0700), @@ -155,13 +155,13 @@ func checkDirectoryPermissionOnCommit(ctx context.Context, t *testing.T, sn snap } // checkStatInWalk ensures that a stat can be called during a walk -func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { +func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshots.Snapshotter, work string) { prefix := "stats-in-walk-" if err := createNamedSnapshots(ctx, sn, prefix); err != nil { t.Fatal(err) } - err := sn.Walk(ctx, func(ctx context.Context, si snapshot.Info) error { + err := sn.Walk(ctx, func(ctx context.Context, si snapshots.Info) error { if !strings.HasPrefix(si.Name, prefix) { // Only stat snapshots from this test return nil @@ -178,7 +178,7 @@ func checkStatInWalk(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, } } -func createNamedSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter, ns string) error { +func createNamedSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter, ns string) error { c1 := fmt.Sprintf("%sc1", ns) c2 := fmt.Sprintf("%sc2", ns) if _, err := snapshotter.Prepare(ctx, c1+"-a", "", opt); err != nil { diff --git a/snapshot/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go similarity index 93% rename from snapshot/testsuite/testsuite.go rename to snapshots/testsuite/testsuite.go index 30cbbb7dd..e24177ed1 100644 --- a/snapshot/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -13,13 +13,13 @@ import ( "github.com/containerd/containerd/fs/fstest" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/testutil" "github.com/stretchr/testify/assert" ) // SnapshotterSuite runs a test suite on the snapshotter given a factory function. -func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error)) { +func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error)) { restoreMask := clearMask() defer restoreMask() @@ -46,7 +46,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context. t.Run("CloseTwice", makeTest(name, snapshotterFn, closeTwice)) } -func makeTest(name string, snapshotterFn func(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error), fn func(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string)) func(t *testing.T) { +func makeTest(name string, snapshotterFn func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error), fn func(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string)) func(t *testing.T) { return func(t *testing.T) { t.Parallel() @@ -91,12 +91,12 @@ func makeTest(name string, snapshotterFn func(ctx context.Context, root string) } } -var opt = snapshot.WithLabels(map[string]string{ +var opt = snapshots.WithLabels(map[string]string{ "containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), }) // checkSnapshotterBasic tests the basic workflow of a snapshot snapshotter. -func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { initialApplier := fstest.Apply( fstest.CreateFile("/foo", []byte("foo\n"), 0777), fstest.CreateDir("/a", 0755), @@ -145,7 +145,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh } assert.Equal(t, "", si.Parent) - assert.Equal(t, snapshot.KindCommitted, si.Kind) + assert.Equal(t, snapshots.KindCommitted, si.Kind) _, err = snapshotter.Stat(ctx, preparing) if err == nil { @@ -180,7 +180,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh } assert.Equal(t, committed, ni.Parent) - assert.Equal(t, snapshot.KindActive, ni.Kind) + assert.Equal(t, snapshots.KindActive, ni.Kind) nextCommitted := filepath.Join(work, "committed-next") if err := snapshotter.Commit(ctx, nextCommitted, next, opt); err != nil { @@ -193,19 +193,19 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh } assert.Equal(t, committed, si2.Parent) - assert.Equal(t, snapshot.KindCommitted, si2.Kind) + assert.Equal(t, snapshots.KindCommitted, si2.Kind) _, err = snapshotter.Stat(ctx, next) if err == nil { t.Fatalf("%s should no longer be available after Commit", next) } - expected := map[string]snapshot.Info{ + expected := map[string]snapshots.Info{ si.Name: si, si2.Name: si2, } - walked := map[string]snapshot.Info{} // walk is not ordered - assert.NoError(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshot.Info) error { + walked := map[string]snapshots.Info{} // walk is not ordered + assert.NoError(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshots.Info) error { walked[si.Name] = si return nil })) @@ -246,7 +246,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh } // Create a New Layer on top of base layer with Prepare, Stat on new layer, should return Active layer. -func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { preparing := filepath.Join(work, "preparing") if err := os.MkdirAll(preparing, 0777); err != nil { t.Fatal(err) @@ -275,12 +275,12 @@ func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter s t.Fatal(err) } assert.Equal(t, si.Name, preparing) - assert.Equal(t, snapshot.KindActive, si.Kind) + assert.Equal(t, snapshots.KindActive, si.Kind) assert.Equal(t, "", si.Parent) } // Commit a New Layer on top of base layer with Prepare & Commit , Stat on new layer, should return Committed layer. -func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { preparing := filepath.Join(work, "preparing") if err := os.MkdirAll(preparing, 0777); err != nil { t.Fatal(err) @@ -314,12 +314,12 @@ func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotte t.Fatal(err) } assert.Equal(t, si.Name, committed) - assert.Equal(t, snapshot.KindCommitted, si.Kind) + assert.Equal(t, snapshots.KindCommitted, si.Kind) assert.Equal(t, "", si.Parent) } -func snapshotterPrepareMount(ctx context.Context, snapshotter snapshot.Snapshotter, diffPathName string, parent string, work string) (string, error) { +func snapshotterPrepareMount(ctx context.Context, snapshotter snapshots.Snapshotter, diffPathName string, parent string, work string) (string, error) { preparing := filepath.Join(work, diffPathName) if err := os.MkdirAll(preparing, 0777); err != nil { return "", err @@ -341,7 +341,7 @@ func snapshotterPrepareMount(ctx context.Context, snapshotter snapshot.Snapshott } // Given A <- B <- C, B is the parent of C and A is a transitive parent of C (in this case, a "grandparent") -func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work) if err != nil { t.Fatal(err) @@ -395,7 +395,7 @@ func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter } // Creating two layers with Prepare or View with same key must fail. -func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { preparing, err := snapshotterPrepareMount(ctx, snapshotter, "preparing", "", work) if err != nil { t.Fatal(err) @@ -456,7 +456,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter } // Deletion of files/folder of base layer in new layer, On Commit, those files should not be visible. -func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateFile("/foo", []byte("foo\n"), 0777), @@ -474,7 +474,7 @@ func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapsho } //Create three layers. Deleting intermediate layer must fail. -func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work) if err != nil { @@ -533,7 +533,7 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot // a1 - active snapshot, no parent // v1 - view snapshot, v1 is parent // v2 - view snapshot, no parent -func baseTestSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter) error { +func baseTestSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter) error { if _, err := snapshotter.Prepare(ctx, "c1-a", "", opt); err != nil { return err } @@ -561,7 +561,7 @@ func baseTestSnapshots(ctx context.Context, snapshotter snapshot.Snapshotter) er return nil } -func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { t1 := time.Now().UTC() if err := baseTestSnapshots(ctx, snapshotter); err != nil { t.Fatalf("Failed to create base snapshots: %v", err) @@ -569,35 +569,35 @@ func checkUpdate(ctx context.Context, t *testing.T, snapshotter snapshot.Snapsho t2 := time.Now().UTC() testcases := []struct { name string - kind snapshot.Kind + kind snapshots.Kind parent string }{ { name: "c1", - kind: snapshot.KindCommitted, + kind: snapshots.KindCommitted, }, { name: "c2", - kind: snapshot.KindCommitted, + kind: snapshots.KindCommitted, parent: "c1", }, { name: "a1", - kind: snapshot.KindActive, + kind: snapshots.KindActive, parent: "c2", }, { name: "a2", - kind: snapshot.KindActive, + kind: snapshots.KindActive, }, { name: "v1", - kind: snapshot.KindView, + kind: snapshots.KindView, parent: "c2", }, { name: "v2", - kind: snapshot.KindView, + kind: snapshots.KindView, }, } for _, tc := range testcases { @@ -717,7 +717,7 @@ func assertLabels(t *testing.T, actual, expected map[string]string) { } } -func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { if _, err := snapshotter.Prepare(ctx, "committed-a", "", opt); err != nil { t.Fatal(err) } @@ -749,7 +749,7 @@ func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshot.Snapsho // checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem. // This function is called only when WithTestViewReadonly is true. -func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { preparing := filepath.Join(work, "preparing") if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil { t.Fatal(err) @@ -786,7 +786,7 @@ func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter // Move files from base layer to new location in intermediate layer. // Verify if the file at source is deleted and copied to new location. -func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { l1Init := fstest.Apply( fstest.CreateDir("/dir1", 0700), fstest.CreateFile("/dir1/f1", []byte("Hello"), 0644), @@ -806,7 +806,7 @@ func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snap } } -func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { +func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { // do some dummy ops to modify the snapshotter internal state if _, err := snapshotter.Prepare(ctx, "dummy", ""); err != nil { t.Fatal(err) diff --git a/snapshot/testsuite/testsuite_unix.go b/snapshots/testsuite/testsuite_unix.go similarity index 100% rename from snapshot/testsuite/testsuite_unix.go rename to snapshots/testsuite/testsuite_unix.go diff --git a/snapshot/testsuite/testsuite_windows.go b/snapshots/testsuite/testsuite_windows.go similarity index 100% rename from snapshot/testsuite/testsuite_windows.go rename to snapshots/testsuite/testsuite_windows.go diff --git a/snapshot/windows/windows.go b/snapshots/windows/windows.go similarity index 81% rename from snapshot/windows/windows.go rename to snapshots/windows/windows.go index a72fa4b07..603428e17 100644 --- a/snapshot/windows/windows.go +++ b/snapshots/windows/windows.go @@ -7,7 +7,7 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshot" + "github.com/containerd/containerd/snapshots" "github.com/pkg/errors" ) @@ -31,7 +31,7 @@ type snapshotter struct { } // NewSnapshotter returns a new windows snapshotter -func NewSnapshotter(root string) (snapshot.Snapshotter, error) { +func NewSnapshotter(root string) (snapshots.Snapshotter, error) { return &snapshotter{ root: root, }, nil @@ -42,23 +42,23 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) { // // Should be used for parent resolution, existence checks and to discern // the kind of snapshot. -func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { +func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) { panic("not implemented") } -func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { +func (o *snapshotter) Update(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) { panic("not implemented") } -func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { +func (o *snapshotter) Usage(ctx context.Context, key string) (snapshots.Usage, error) { panic("not implemented") } -func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { +func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { panic("not implemented") } -func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { +func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) { panic("not implemented") } @@ -70,7 +70,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er panic("not implemented") } -func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { +func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error { panic("not implemented") } @@ -81,7 +81,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) error { } // Walk the committed snapshots. -func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { +func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshots.Info) error) error { panic("not implemented") }