feat: single namespace (#65)

Closes #64
Closes #63
This commit is contained in:
Jakub Błaszczyk
2021-05-13 13:50:21 +02:00
committed by GitHub
parent 2658f82cc6
commit 0d726dd0b7
11 changed files with 315 additions and 195 deletions

View File

@ -18,7 +18,6 @@ package controllers
import (
"context"
"fmt"
"github.com/go-logr/logr"
hydrav1alpha1 "github.com/ory/hydra-maester/api/v1alpha1"
"github.com/ory/hydra-maester/hydra"
@ -58,6 +57,7 @@ type OAuth2ClientReconciler struct {
Log logr.Logger
otherClients map[clientMapKey]HydraClientInterface
client.Client
ControllerNamespace string
}
// +kubebuilder:rbac:groups=hydra.ory.sh,resources=oauth2clients,verbs=get;list;watch;create;update;patch;delete
@ -78,6 +78,15 @@ func (r *OAuth2ClientReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, err
}
// Check request namespace
if r.ControllerNamespace != "" {
r.Log.Info((fmt.Sprintf("ControllerNamespace is set to: %s, working only on items in this namespace. Other namespaces are ignored.", r.ControllerNamespace)))
if req.NamespacedName.Namespace != r.ControllerNamespace {
r.Log.Info((fmt.Sprintf("Requested resource %s is not in namespace: %s and will be ignored", req.String(), r.ControllerNamespace)))
return ctrl.Result{}, nil
}
}
// examine DeletionTimestamp to determine if object is under deletion
if oauth2client.ObjectMeta.DeletionTimestamp.IsZero() {
// The object is not being deleted, so if it does not have our finalizer,