Skip to content

Commit

Permalink
fix: don't set empty image pull secrets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oliver-rew-rigado committed Jan 24, 2022
1 parent 2e1acdc commit 25977e3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/rabbitmqcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ func (r *RabbitmqClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}

if rabbitmqCluster.Spec.ImagePullSecrets == nil {
// split the comma separated list of default image pull secrets from
// the 'DEFAULT_IMAGE_PULL_SECRETS' env var, but ignore empty strings.
for _, reference := range strings.Split(r.DefaultImagePullSecrets, ",") {
rabbitmqCluster.Spec.ImagePullSecrets = append(rabbitmqCluster.Spec.ImagePullSecrets, corev1.LocalObjectReference{Name: reference})
if len(reference) > 0 {
rabbitmqCluster.Spec.ImagePullSecrets = append(rabbitmqCluster.Spec.ImagePullSecrets, corev1.LocalObjectReference{Name: reference})
}
}
if err = r.Update(ctx, rabbitmqCluster); err != nil {
if k8serrors.IsConflict(err) {
Expand Down

0 comments on commit 25977e3

Please sign in to comment.