minor fixes for tests to run

Signed-off-by: Sam Lockart <sam.lockart@zendesk.com>
This commit is contained in:
Sam Lockart 2024-11-18 16:55:58 +11:00
parent 5a51c20887
commit 96934b23d1
2 changed files with 10 additions and 8 deletions

View File

@ -72,15 +72,17 @@ func New(opts ...Option) (engine.Interface, error) {
return nil, fmt.Errorf("failed to load config: %v", err) return nil, fmt.Errorf("failed to load config: %v", err)
} }
useLegacyConfig := b.configVersion == 1
cfg := &Config{ cfg := &Config{
Tree: tomlConfig, Tree: tomlConfig,
Logger: b.logger, Logger: b.logger,
RuntimeType: b.runtimeType, RuntimeType: b.runtimeType,
UseDefaultRuntimeName: b.useLegacyConfig, UseDefaultRuntimeName: useLegacyConfig,
ContainerAnnotations: b.containerAnnotations, ContainerAnnotations: b.containerAnnotations,
} }
version, err := cfg.parseVersion(b.useLegacyConfig) version, err := cfg.parseVersion(useLegacyConfig)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to parse config version: %v", err) return nil, fmt.Errorf("failed to parse config version: %v", err)
} }

View File

@ -29,7 +29,7 @@ import (
) )
const ( const (
runtimeType = "runtime_type" runtimeTypeV3 = "runtime_type"
) )
func TestUpdateV3ConfigDefaultRuntime(t *testing.T) { func TestUpdateV3ConfigDefaultRuntime(t *testing.T) {
@ -78,7 +78,7 @@ func TestUpdateV3ConfigDefaultRuntime(t *testing.T) {
v3 := &containerd.ConfigV3{ v3 := &containerd.ConfigV3{
Logger: logger, Logger: logger,
Tree: cfg, Tree: cfg,
RuntimeType: runtimeType, RuntimeType: runtimeTypeV3,
} }
err = o.UpdateConfig(v3) err = o.UpdateConfig(v3)
@ -201,7 +201,7 @@ func TestUpdateV3Config(t *testing.T) {
v3 := &containerd.ConfigV3{ v3 := &containerd.ConfigV3{
Logger: logger, Logger: logger,
Tree: cfg, Tree: cfg,
RuntimeType: runtimeType, RuntimeType: runtimeTypeV3,
ContainerAnnotations: []string{"cdi.k8s.io/*"}, ContainerAnnotations: []string{"cdi.k8s.io/*"},
} }
@ -354,7 +354,7 @@ func TestUpdateV3ConfigWithRuncPresent(t *testing.T) {
v3 := &containerd.ConfigV3{ v3 := &containerd.ConfigV3{
Logger: logger, Logger: logger,
Tree: cfg, Tree: cfg,
RuntimeType: runtimeType, RuntimeType: runtimeTypeV3,
ContainerAnnotations: []string{"cdi.k8s.io/*"}, ContainerAnnotations: []string{"cdi.k8s.io/*"},
} }
@ -426,7 +426,7 @@ func TestRevertV3Config(t *testing.T) {
v3 := &containerd.ConfigV3{ v3 := &containerd.ConfigV3{
Tree: cfg, Tree: cfg,
RuntimeType: runtimeType, RuntimeType: runtimeTypeV3,
} }
err = o.RevertConfig(v3) err = o.RevertConfig(v3)
@ -442,7 +442,7 @@ func TestRevertV3Config(t *testing.T) {
func runtimeMapV3(binary string) map[string]interface{} { func runtimeMapV3(binary string) map[string]interface{} {
return map[string]interface{}{ return map[string]interface{}{
"runtime_type": runtimeType, "runtime_type": runtimeTypeV3,
"runtime_root": "", "runtime_root": "",
"runtime_engine": "", "runtime_engine": "",
"privileged_without_host_devices": false, "privileged_without_host_devices": false,