Skip to content

Commit 25977e3

Browse files
fix: don't set empty image pull secrets
commit "5f98b43" added the ability to set image pull secrets from the DEFAULT_IMAGE_PULL_SECRETS env var, when they are not otherwise set. However, this introduced a regression, when neither were set, where an empty image pull secret would be saved. This fix adds a check to ensure any saved image pull secrets are not empty.
1 parent 2e1acdc commit 25977e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

controllers/rabbitmqcluster_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ func (r *RabbitmqClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ
131131
}
132132

133133
if rabbitmqCluster.Spec.ImagePullSecrets == nil {
134+
// split the comma separated list of default image pull secrets from
135+
// the 'DEFAULT_IMAGE_PULL_SECRETS' env var, but ignore empty strings.
134136
for _, reference := range strings.Split(r.DefaultImagePullSecrets, ",") {
135-
rabbitmqCluster.Spec.ImagePullSecrets = append(rabbitmqCluster.Spec.ImagePullSecrets, corev1.LocalObjectReference{Name: reference})
137+
if len(reference) > 0 {
138+
rabbitmqCluster.Spec.ImagePullSecrets = append(rabbitmqCluster.Spec.ImagePullSecrets, corev1.LocalObjectReference{Name: reference})
139+
}
136140
}
137141
if err = r.Update(ctx, rabbitmqCluster); err != nil {
138142
if k8serrors.IsConflict(err) {

0 commit comments

Comments
 (0)