From 38045534f407e32e67b25860b3996266a3a7c724 Mon Sep 17 00:00:00 2001 From: mgandharva Date: Fri, 10 Jan 2025 02:22:29 -0500 Subject: [PATCH] fix: unit test --- pkg/drivers/commonconfig.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/commonconfig.go b/pkg/drivers/commonconfig.go index 7c1df1f7..ea78fce3 100644 --- a/pkg/drivers/commonconfig.go +++ b/pkg/drivers/commonconfig.go @@ -106,8 +106,15 @@ func GetController(ctx context.Context, cr csmv1.ContainerStorageModule, operato c.Image = &image } } - if cr.Spec.Driver.Controller != nil { - containers[i].Env = utils.ReplaceAllApplyCustomEnvs(c.Env, cr.Spec.Driver.Common.Envs, cr.Spec.Driver.Controller.Envs) + if cr.Spec.Driver.Common != nil || cr.Spec.Driver.Controller != nil { + var commonEnvs, controllerEnvs []corev1.EnvVar + if cr.Spec.Driver.Common != nil { + commonEnvs = cr.Spec.Driver.Common.Envs + } + if cr.Spec.Driver.Controller != nil { + controllerEnvs = cr.Spec.Driver.Controller.Envs + } + containers[i].Env = utils.ReplaceAllApplyCustomEnvs(c.Env, commonEnvs, controllerEnvs) c.Env = containers[i].Env } }