This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A CastParent reconciler casts the ParentReconciler's type by projecting the resource data onto a new struct. Casting the parent resource is useful to create cross cutting reconcilers that can operate on common portion of multiple parent resources, commonly referred to as a duck type. JSON encoding is used as the intermediate representation. Operations on a cast parent are read-only. Attempts to mutate the parent will result in the reconciler erring. ``` func FunctionReconciler(c reconcilers.Config) *reconcilers.ParentReconciler { c.Log = c.Log.WithName("Function") return &reconcilers.ParentReconciler{ Type: &buildv1alpha1.Function{}, Reconciler: reconcilers.Sequence{ &reconcilers.CastParent{ Type: &duckv1alpha1.ImageRef{}, Reconciler: &reconcilers.SyncReconciler{ Sync: func(ctx context.Context, parent *duckv1alpha1.ImageRef) error { // do something with the duckv1alpha1.ImageRef instead of a buildv1alpha1.Function return nil }, Config: c, }, }, FunctionChildImageReconciler(c), }, Config: c, } } ``` Signed-off-by: Scott Andrews <[email protected]> Co-authored-by: Glyn Normington <[email protected]>
- Loading branch information
Showing
7 changed files
with
429 additions
and
11 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
Oops, something went wrong.