Allow specify base OCI runtime spec
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/containerd/oci"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -381,3 +382,23 @@ func TestContainerAnnotationPassthroughContainerSpec(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseRuntimeSpec(t *testing.T) {
|
||||
c := newTestCRIService()
|
||||
c.baseOCISpecs = map[string]*oci.Spec{
|
||||
"/etc/containerd/cri-base.json": {
|
||||
Version: "1.0.2",
|
||||
Hostname: "old",
|
||||
},
|
||||
}
|
||||
|
||||
out, err := c.runtimeSpec("id1", "/etc/containerd/cri-base.json", oci.WithHostname("new"))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "1.0.2", out.Version)
|
||||
assert.Equal(t, "new", out.Hostname)
|
||||
|
||||
// Make sure original base spec not changed
|
||||
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
|
||||
assert.Equal(t, c.baseOCISpecs["/etc/containerd/cri-base.json"].Hostname, "old")
|
||||
}
|
||||
|
Reference in New Issue
Block a user