Skip to content

Commit

Permalink
Merge pull request #74 from m00g3n/add-predicates
Browse files Browse the repository at this point in the history
Add predicates to filter out CR status changes
  • Loading branch information
m00g3n authored Nov 29, 2023
2 parents 65e4ecb + 3882f23 commit ab63ecf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ endif

.PHONY: gardener-secret-deploy
gardener-secret-deploy:
$(KUBECTL) create secret generic gardener-credentials --from-file kubeconfig=$(GARDENER_KUBECONFIG_PATH) -n kcp-system
$(KUBECTL) create secret generic gardener-credentials --from-file kubeconfig=$(GARDENER_KUBECONFIG_PATH) -n kcp-system --dry-run=client -o yaml | kubectl apply -f -

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
Expand Down
7 changes: 6 additions & 1 deletion internal/controller/gardener_cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const (
Expand Down Expand Up @@ -394,6 +395,10 @@ func (controller *GardenerClusterController) newSecret(cluster imv1.GardenerClus
// SetupWithManager sets up the controller with the Manager.
func (controller *GardenerClusterController) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&imv1.GardenerCluster{}, builder.WithPredicates()).
For(&imv1.GardenerCluster{}, builder.WithPredicates(predicate.Or(
predicate.LabelChangedPredicate{},
predicate.AnnotationChangedPredicate{},
predicate.GenerationChangedPredicate{}),
)).
Complete(controller)
}

0 comments on commit ab63ecf

Please sign in to comment.