Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add predicates to filter out CR status changes #74

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading