Last active
August 29, 2019 13:44
-
-
Save isutton/8e3eeb0f08d42bd5ba65a4132bf01f5d to your computer and use it in GitHub Desktop.
Watch from Mapper example
This file contains hidden or 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
type CRDToWatchMapper { | |
c *Controller | |
} | |
func (m *CRDToWatchMapper) Map(obj handler.MapObject) []reconcile.Request { | |
crdGvk := extractGVKFromCRD(obj.Object) | |
m.c.Watch( | |
createSourceForGVK(crdGvk), | |
&handler.EnqueueRequestsFromMapFunc{ToRequests: &SBRRequestMapper{}}, | |
) | |
return []reconcile.Request{} | |
} | |
func add() { | |
// ... | |
err := c.Watch( | |
createSourceForGVK(v1.SchemeGroupVersion.WithKind("CustomResourceDefinition")), | |
&handler.EnqueueRequestsFromMapFunc{ToRequests: &CRDToWatchMapper{c: c}}, | |
) | |
if err != nil { | |
return err | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment