From b93a1197177818505ee228869e3a604314067bdb Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Sat, 19 Oct 2024 21:42:55 -0500 Subject: [PATCH] chore: Simplify default container detection --- internal/util/cmd_setup.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/util/cmd_setup.go b/internal/util/cmd_setup.go index 2608687..58d2a2f 100644 --- a/internal/util/cmd_setup.go +++ b/internal/util/cmd_setup.go @@ -274,11 +274,12 @@ func CreateJob(ctx context.Context, conf *config.Global, opts SetupOptions) erro } func createJob(ctx context.Context, conf *config.Global, actionName string) error { - image := conf.DBPod.Spec.Containers[0].Image + defaultContainer := conf.DBPod.Spec.Containers[0] if name := conf.DBPod.Annotations[podcmd.DefaultContainerAnnotationName]; name != "" { for _, container := range conf.DBPod.Spec.Containers { if container.Name == name { - image = container.Image + defaultContainer = container + break } } } @@ -357,10 +358,10 @@ func createJob(ctx context.Context, conf *config.Global, actionName string) erro Containers: []corev1.Container{ { Name: "kubedb", - Image: image, + Image: defaultContainer.Image, ImagePullPolicy: corev1.PullIfNotPresent, Command: []string{"sleep", "infinity"}, - SecurityContext: conf.DBPod.Spec.Containers[0].SecurityContext, + SecurityContext: defaultContainer.SecurityContext, }, }, SecurityContext: conf.DBPod.Spec.SecurityContext,