api: RootFS -> SnapshotKey

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Akihiro Suda
2017-09-04 07:02:43 +00:00
committed by Stephen J Day
parent 8b63386924
commit e30e0c8b75
17 changed files with 168 additions and 171 deletions

View File

@@ -47,7 +47,7 @@ var (
bucketKeyParent = []byte("parent")
bucketKeyOptions = []byte("options")
bucketKeySpec = []byte("spec")
bucketKeyRootFS = []byte("rootfs")
bucketKeySnapshotKey = []byte("snapshotKey")
bucketKeySnapshotter = []byte("snapshotter")
bucketKeyTarget = []byte("target")
)

View File

@@ -155,8 +155,8 @@ func (s *containerStore) Update(ctx context.Context, container containers.Contai
return containers.Container{}, errors.Wrapf(errdefs.ErrInvalidArgument, "container.Image field is immutable")
}
if updated.RootFS != container.RootFS {
return containers.Container{}, errors.Wrapf(errdefs.ErrInvalidArgument, "container.RootFS field is immutable")
if updated.SnapshotKey != container.SnapshotKey {
return containers.Container{}, errors.Wrapf(errdefs.ErrInvalidArgument, "container.SnapshotKey field is immutable")
}
if updated.Snapshotter != container.Snapshotter {
@@ -235,8 +235,8 @@ func validateContainer(container *containers.Container) error {
return errors.Wrapf(errdefs.ErrInvalidArgument, "container.Spec must be set")
}
if container.RootFS != "" && container.Snapshotter == "" {
return errors.Wrapf(errdefs.ErrInvalidArgument, "container.Snapshotter must be set if container.RootFS is set")
if container.SnapshotKey != "" && container.Snapshotter == "" {
return errors.Wrapf(errdefs.ErrInvalidArgument, "container.Snapshotter must be set if container.SnapshotKey is set")
}
return nil
@@ -284,8 +284,8 @@ func readContainer(container *containers.Container, bkt *bolt.Bucket) error {
return err
}
container.Spec = &any
case string(bucketKeyRootFS):
container.RootFS = string(v)
case string(bucketKeySnapshotKey):
container.SnapshotKey = string(v)
case string(bucketKeySnapshotter):
container.Snapshotter = string(v)
}
@@ -313,7 +313,7 @@ func writeContainer(bkt *bolt.Bucket, container *containers.Container) error {
for _, v := range [][2][]byte{
{bucketKeyImage, []byte(container.Image)},
{bucketKeySnapshotter, []byte(container.Snapshotter)},
{bucketKeyRootFS, []byte(container.RootFS)},
{bucketKeySnapshotKey, []byte(container.SnapshotKey)},
} {
if err := bkt.Put(v[0], v[1]); err != nil {
return err

View File

@@ -45,7 +45,7 @@ func TestContainersList(t *testing.T) {
"odd": fmt.Sprint(i%2 != 0),
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -194,7 +194,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
name: "UpdateIDFail",
original: containers.Container{
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -213,7 +213,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
{
name: "UpdateRuntimeFail",
original: containers.Container{
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Spec: encoded,
Runtime: containers.RuntimeInfo{
@@ -233,7 +233,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
name: "UpdateRuntimeClearFail",
original: containers.Container{
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -249,7 +249,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
name: "UpdateFail",
original: containers.Container{
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
@@ -262,7 +262,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
// try to clear image field
},
@@ -272,7 +272,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
name: "UpdateSpec",
original: containers.Container{
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -288,7 +288,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
Name: "testruntime",
},
Spec: encodedUpdated,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Image: "test image",
},
@@ -301,7 +301,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
"bar": "two",
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -320,7 +320,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
"bar": "baz",
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -336,7 +336,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
"bar": "two",
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -349,7 +349,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
fieldpaths: []string{"labels"},
expected: containers.Container{
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -365,7 +365,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
"bar": "two",
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -383,7 +383,7 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
"foo": "one",
},
Spec: encoded,
RootFS: "test-rootfs",
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
@@ -392,27 +392,27 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
},
},
{
name: "UpdateRootFSImmutable",
name: "UpdateSnapshotKeyImmutable",
original: containers.Container{
Spec: encoded,
RootFS: "",
SnapshotKey: "",
Snapshotter: "",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
},
input: containers.Container{
RootFS: "something",
SnapshotKey: "something",
Snapshotter: "something",
},
fieldpaths: []string{"rootfs", "snapshotter"},
fieldpaths: []string{"snapshotkey", "snapshotter"},
cause: errdefs.ErrInvalidArgument,
},
{
name: "RootFSWithoutSnapshot",
name: "SnapshotKeyWithoutSnapshot",
original: containers.Container{
Spec: encoded,
RootFS: "/nosnapshot",
SnapshotKey: "/nosnapshot",
Snapshotter: "",
Runtime: containers.RuntimeInfo{
Name: "testruntime",