From 2b417c1a9acc1549d4846e84379031111b98a332 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 27 Jan 2025 15:37:06 +0100 Subject: [PATCH] Fix overwriting docker feature flags Signed-off-by: Evan Lezar --- pkg/config/engine/docker/docker.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/config/engine/docker/docker.go b/pkg/config/engine/docker/docker.go index 83d68615..86512df9 100644 --- a/pkg/config/engine/docker/docker.go +++ b/pkg/config/engine/docker/docker.go @@ -105,7 +105,20 @@ func (c Config) DefaultRuntime() string { // EnableCDI sets features.cdi to true in the docker config. func (c *Config) EnableCDI() { - (*c)["features"] = map[string]bool{"cdi": true} + if c == nil { + return + } + config := *c + + features, ok := config["features"].(map[string]bool) + if !ok { + features = make(map[string]bool) + } + features["cdi"] = true + + config["features"] = features + + *c = config } // RemoveRuntime removes a runtime from the docker config