mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
oci: remove unused function GetContainerType
This is unused - we utilize ContainerType directly. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
e34893a0c4
commit
b6ebddd7ef
@ -323,18 +323,6 @@ func networkConfig(ocispec specs.Spec, config RuntimeConfig) (vc.NetworkConfig,
|
|||||||
return netConf, nil
|
return netConf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerType determines which type of container matches the annotations
|
|
||||||
// table provided.
|
|
||||||
func GetContainerType(annotations map[string]string) (vc.ContainerType, error) {
|
|
||||||
if containerType, ok := annotations[vcAnnotations.ContainerTypeKey]; ok {
|
|
||||||
return vc.ContainerType(containerType), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ociLog.Errorf("Annotations[%s] not found, cannot determine the container type",
|
|
||||||
vcAnnotations.ContainerTypeKey)
|
|
||||||
return vc.UnknownContainerType, fmt.Errorf("Could not find container type")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContainerType returns the type of container and if the container type was
|
// ContainerType returns the type of container and if the container type was
|
||||||
// found from CRI servers annotations.
|
// found from CRI servers annotations.
|
||||||
func ContainerType(spec specs.Spec) (vc.ContainerType, error) {
|
func ContainerType(spec specs.Spec) (vc.ContainerType, error) {
|
||||||
|
@ -188,38 +188,6 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
assert.NoError(os.Remove(configPath))
|
assert.NoError(os.Remove(configPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetContainerTypeSuccessful(t *testing.T, annotations map[string]string, expected vc.ContainerType) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
containerType, err := GetContainerType(annotations)
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal(containerType, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetContainerTypePodSandbox(t *testing.T) {
|
|
||||||
annotations := map[string]string{
|
|
||||||
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
|
|
||||||
}
|
|
||||||
|
|
||||||
testGetContainerTypeSuccessful(t, annotations, vc.PodSandbox)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetContainerTypePodContainer(t *testing.T) {
|
|
||||||
annotations := map[string]string{
|
|
||||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
|
||||||
}
|
|
||||||
|
|
||||||
testGetContainerTypeSuccessful(t, annotations, vc.PodContainer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetContainerTypeFailure(t *testing.T) {
|
|
||||||
expected := vc.UnknownContainerType
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
containerType, err := GetContainerType(map[string]string{})
|
|
||||||
assert.Error(err)
|
|
||||||
assert.Equal(containerType, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testContainerTypeSuccessful(t *testing.T, ociSpec specs.Spec, expected vc.ContainerType) {
|
func testContainerTypeSuccessful(t *testing.T, ociSpec specs.Spec, expected vc.ContainerType) {
|
||||||
containerType, err := ContainerType(ociSpec)
|
containerType, err := ContainerType(ociSpec)
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
Loading…
Reference in New Issue
Block a user