From 96934b23d1e87fdc9237518bd5a9c017a7aa3dd3 Mon Sep 17 00:00:00 2001 From: Sam Lockart Date: Mon, 18 Nov 2024 16:55:58 +1100 Subject: [PATCH] minor fixes for tests to run Signed-off-by: Sam Lockart --- pkg/config/engine/containerd/containerd.go | 6 ++++-- tools/container/runtime/containerd/config_v3_test.go | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/config/engine/containerd/containerd.go b/pkg/config/engine/containerd/containerd.go index cec4f3e2..e94e34fb 100644 --- a/pkg/config/engine/containerd/containerd.go +++ b/pkg/config/engine/containerd/containerd.go @@ -72,15 +72,17 @@ func New(opts ...Option) (engine.Interface, error) { return nil, fmt.Errorf("failed to load config: %v", err) } + useLegacyConfig := b.configVersion == 1 + cfg := &Config{ Tree: tomlConfig, Logger: b.logger, RuntimeType: b.runtimeType, - UseDefaultRuntimeName: b.useLegacyConfig, + UseDefaultRuntimeName: useLegacyConfig, ContainerAnnotations: b.containerAnnotations, } - version, err := cfg.parseVersion(b.useLegacyConfig) + version, err := cfg.parseVersion(useLegacyConfig) if err != nil { return nil, fmt.Errorf("failed to parse config version: %v", err) } diff --git a/tools/container/runtime/containerd/config_v3_test.go b/tools/container/runtime/containerd/config_v3_test.go index 10482bad..c60a71f7 100644 --- a/tools/container/runtime/containerd/config_v3_test.go +++ b/tools/container/runtime/containerd/config_v3_test.go @@ -29,7 +29,7 @@ import ( ) const ( - runtimeType = "runtime_type" + runtimeTypeV3 = "runtime_type" ) func TestUpdateV3ConfigDefaultRuntime(t *testing.T) { @@ -78,7 +78,7 @@ func TestUpdateV3ConfigDefaultRuntime(t *testing.T) { v3 := &containerd.ConfigV3{ Logger: logger, Tree: cfg, - RuntimeType: runtimeType, + RuntimeType: runtimeTypeV3, } err = o.UpdateConfig(v3) @@ -201,7 +201,7 @@ func TestUpdateV3Config(t *testing.T) { v3 := &containerd.ConfigV3{ Logger: logger, Tree: cfg, - RuntimeType: runtimeType, + RuntimeType: runtimeTypeV3, ContainerAnnotations: []string{"cdi.k8s.io/*"}, } @@ -354,7 +354,7 @@ func TestUpdateV3ConfigWithRuncPresent(t *testing.T) { v3 := &containerd.ConfigV3{ Logger: logger, Tree: cfg, - RuntimeType: runtimeType, + RuntimeType: runtimeTypeV3, ContainerAnnotations: []string{"cdi.k8s.io/*"}, } @@ -426,7 +426,7 @@ func TestRevertV3Config(t *testing.T) { v3 := &containerd.ConfigV3{ Tree: cfg, - RuntimeType: runtimeType, + RuntimeType: runtimeTypeV3, } err = o.RevertConfig(v3) @@ -442,7 +442,7 @@ func TestRevertV3Config(t *testing.T) { func runtimeMapV3(binary string) map[string]interface{} { return map[string]interface{}{ - "runtime_type": runtimeType, + "runtime_type": runtimeTypeV3, "runtime_root": "", "runtime_engine": "", "privileged_without_host_devices": false,