Skip to content

Commit

Permalink
Merge pull request #4 from christianwoehrle/fix/KeepClientSecret
Browse files Browse the repository at this point in the history
Fix/keep client secret
  • Loading branch information
christianwoehrle authored Oct 9, 2022
2 parents a990e3e + 6b3a865 commit 00daa08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/controller/keycloakclient/keycloakclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,19 @@ func (r *ReconcileKeycloakClient) Reconcile(request reconcile.Request) (reconcil
}
}
}
err = r.manageSuccess(instance, instance.DeletionTimestamp != nil)

if err != nil {
log.Error(err, "unable to update status")
return reconcile.Result{
RequeueAfter: RequeueDelayError,
Requeue: true,
}, nil
}

log.Info("desired cluster state met")
return reconcile.Result{Requeue: false}, err

return reconcile.Result{Requeue: false}, r.manageSuccess(instance, instance.DeletionTimestamp != nil)
}

// Fills the CR with default values. Nils are not acceptable for Kubernetes.
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/keycloakclient/keycloakclient_reconciler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keycloakclient

import (
"bytes"
"fmt"

"github.com/christianwoehrle/keycloakclient-operator/pkg/controller/keycloakuser"
Expand Down Expand Up @@ -38,6 +39,14 @@ func (i *KeycloakClientReconciler) Reconcile(state *common.ClientState, cr *kc.K
}

if state.Client == nil {
if cr.Spec.Client.Secret == "" {
if state.ClientSecret != nil {
if !bytes.Equal(state.ClientSecret.Data["CLIENT_SECRET"], []byte("")) {
log.Info("reconstruct Secret for " + cr.Spec.Client.ID)
cr.Spec.Client.Secret = string(state.ClientSecret.Data["CLIENT_SECRET"])
}
}
}
desired.AddAction(i.getCreatedClientState(state, cr))
} else {
desired.AddAction(i.getUpdatedClientState(state, cr))
Expand Down

0 comments on commit 00daa08

Please sign in to comment.