Allow image and snapshotkey to be updated

This allows a container's image and snapshot key to be updated via the
Update APIs.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2018-04-05 16:43:08 -04:00
parent 2bc17ef2cb
commit 9af8d56cdd
2 changed files with 59 additions and 32 deletions

View File

@@ -263,29 +263,6 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
fieldpaths: []string{"runtime"},
cause: errdefs.ErrInvalidArgument,
},
{
name: "UpdateFail",
original: containers.Container{
Spec: encoded,
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
Image: "test image",
},
input: containers.Container{
Spec: encoded,
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
// try to clear image field
},
cause: errdefs.ErrInvalidArgument,
},
{
name: "UpdateSpec",
original: containers.Container{
@@ -311,6 +288,60 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
Image: "test image",
},
},
{
name: "UpdateSnapshot",
original: containers.Container{
Spec: encoded,
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
Image: "test image",
},
input: containers.Container{
SnapshotKey: "test2-snapshot-key",
},
fieldpaths: []string{"snapshotkey"},
expected: containers.Container{
Spec: encoded,
SnapshotKey: "test2-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
Image: "test image",
},
},
{
name: "UpdateImage",
original: containers.Container{
Spec: encoded,
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
Image: "test image",
},
input: containers.Container{
Image: "test2 image",
},
fieldpaths: []string{"image"},
expected: containers.Container{
Spec: encoded,
SnapshotKey: "test-snapshot-key",
Snapshotter: "snapshotter",
Runtime: containers.RuntimeInfo{
Name: "testruntime",
},
Image: "test2 image",
},
},
{
name: "UpdateLabel",
original: containers.Container{