Skip to content

Commit

Permalink
chore: Simplify default container detection
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 20, 2024
1 parent af081ef commit b93a119
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/util/cmd_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b93a119

Please sign in to comment.