Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2028 from WeiZhang555/remove-annotation-ConfigJSO…
Browse files Browse the repository at this point in the history
…NKey

Remove annotation config json key
  • Loading branch information
bergwolf authored Sep 18, 2019
2 parents b86ab21 + 2ed94cb commit 74e7d3d
Show file tree
Hide file tree
Showing 31 changed files with 574 additions and 564 deletions.
3 changes: 2 additions & 1 deletion cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/kata-containers/runtime/pkg/katautils"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/pkg/compatoci"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -113,7 +114,7 @@ func create(ctx context.Context, containerID, bundlePath, console, pidFilePath s
return err
}

ociSpec, err := oci.ParseConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
if err != nil {
return err
}
Expand Down
13 changes: 7 additions & 6 deletions cli/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
ktu "github.com/kata-containers/runtime/pkg/katatestutils"
"github.com/kata-containers/runtime/pkg/katautils"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/pkg/compatoci"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
specs "github.com/opencontainers/runtime-spec/specs-go"
Expand Down Expand Up @@ -322,7 +323,7 @@ func TestCreateInvalidContainerType(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

// Force an invalid container type
Expand Down Expand Up @@ -367,7 +368,7 @@ func TestCreateContainerInvalid(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)

assert.NoError(err)

Expand Down Expand Up @@ -432,7 +433,7 @@ func TestCreateProcessCgroupsPathSuccessful(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

// Force sandbox-type container
Expand Down Expand Up @@ -535,7 +536,7 @@ func TestCreateCreateCgroupsFilesFail(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

// Force sandbox-type container
Expand Down Expand Up @@ -622,7 +623,7 @@ func TestCreateCreateCreatePidFileFail(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

// Force sandbox-type container
Expand Down Expand Up @@ -697,7 +698,7 @@ func TestCreate(t *testing.T) {
ociConfigFile := filepath.Join(bundlePath, "config.json")
assert.True(katautils.FileExists(ociConfigFile))

spec, err := oci.ParseConfigJSON(bundlePath)
spec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

// Force sandbox-type container
Expand Down
31 changes: 17 additions & 14 deletions cli/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/urfave/cli"

ktu "github.com/kata-containers/runtime/pkg/katatestutils"
vc "github.com/kata-containers/runtime/virtcontainers"
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
"github.com/kata-containers/runtime/virtcontainers/pkg/compatoci"
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
"github.com/kata-containers/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli"
)

func testRemoveCgroupsPathSuccessful(t *testing.T, cgroupsPathList []string) {
Expand Down Expand Up @@ -153,7 +155,8 @@ func TestDeleteSandbox(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)

ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.ID(), sandbox.ID())
Expand All @@ -165,11 +168,11 @@ func TestDeleteSandbox(t *testing.T) {
ID: sandbox.ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "ready",
},
Spec: &ociSpec,
}, nil
}

Expand Down Expand Up @@ -231,7 +234,7 @@ func TestDeleteInvalidContainerType(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.ID(), sandbox.ID())
Expand All @@ -243,11 +246,11 @@ func TestDeleteInvalidContainerType(t *testing.T) {
ID: sandbox.ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: "InvalidType",
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "created",
},
Spec: &ociSpec,
}, nil
}

Expand All @@ -270,7 +273,7 @@ func TestDeleteSandboxRunning(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.ID(), sandbox.ID())
Expand All @@ -282,11 +285,11 @@ func TestDeleteSandboxRunning(t *testing.T) {
ID: sandbox.ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "running",
},
Spec: &ociSpec,
}, nil
}

Expand Down Expand Up @@ -350,7 +353,7 @@ func TestDeleteRunningContainer(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.MockContainers[0].ID(), sandbox.MockContainers[0].ID())
Expand All @@ -362,11 +365,11 @@ func TestDeleteRunningContainer(t *testing.T) {
ID: sandbox.MockContainers[0].ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "running",
},
Spec: &ociSpec,
}, nil
}

Expand Down Expand Up @@ -433,7 +436,7 @@ func TestDeleteContainer(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.MockContainers[0].ID(), sandbox.MockContainers[0].ID())
Expand All @@ -445,11 +448,11 @@ func TestDeleteContainer(t *testing.T) {
ID: sandbox.MockContainers[0].ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "ready",
},
Spec: &ociSpec,
}, nil
}

Expand Down Expand Up @@ -533,7 +536,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {

rootPath, bundlePath := testConfigSetup(t)
defer os.RemoveAll(rootPath)
configJSON, err := readOCIConfigJSON(bundlePath)
ociSpec, err := compatoci.ParseConfigJSON(bundlePath)
assert.NoError(err)

path, err := createTempContainerIDMapping(sandbox.ID(), sandbox.ID())
Expand All @@ -545,11 +548,11 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
ID: sandbox.ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.ContainerState{
State: "ready",
},
Spec: &ociSpec,
}, nil
}

Expand Down
Loading

0 comments on commit 74e7d3d

Please sign in to comment.