-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle CP refs in Consumer, ConsumerGroup and Vault reconcilers
- Loading branch information
Showing
7 changed files
with
398 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 63 additions & 18 deletions
81
internal/controllers/configuration/zz_generated_controllers.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package utils | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/predicate" | ||
|
||
kongv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" | ||
) | ||
|
||
// ObjectWithControlPlaneRef is an interface that represents an object that has a control plane reference. | ||
type ObjectWithControlPlaneRef interface { | ||
GetControlPlaneRef() *kongv1alpha1.ControlPlaneRef | ||
} | ||
|
||
// GenerateCPReferenceMatchesPredicate generates a predicate function that filters out objects that have a control plane | ||
// reference set to a value other than 'kic'. | ||
func GenerateCPReferenceMatchesPredicate[T ObjectWithControlPlaneRef]() predicate.Predicate { | ||
return predicate.NewPredicateFuncs(func(o client.Object) bool { | ||
c, ok := o.(T) | ||
if !ok { | ||
return false | ||
} | ||
if cpRef := c.GetControlPlaneRef(); cpRef != nil { | ||
// If the cpRef is set, reconcile the object only if it is set explicitly to 'kic'. | ||
return cpRef.Type == kongv1alpha1.ControlPlaneRefKIC | ||
} | ||
// If there's no cpRef set, we should reconcile it as by default it's 'kic'. | ||
return true | ||
}) | ||
} |
Oops, something went wrong.