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

TrackAndGet #232

Merged
merged 1 commit into from May 10, 2022
Merged

TrackAndGet #232

merged 1 commit into from May 10, 2022

Commits on May 9, 2022

  1. TrackAndGet

    Streamline the flow for looking up a resource and watching it for
    changes. The Tracker has long lived on the Config object as a peer to
    the Client, it's very common to Track() a resource and then Get() that
    same resource. Now we can do both, this effectively makes tracking
    transparent as TrackAndGet() and Get() have the same method signature.
    
    Before:
    
        c.Tracker.Track(
            ctx,
            tracker.NewKey(
               schema.GroupVersionKind{Version: "v1", Kind: "ServiceAccount"},
               types.NamespacedName{Namespace: parent.Namespace, Name: serviceAccountName},
            ),
            types.NamespacedName{Namespace: parent.Namespace, Name: parent.Name},
        )
        serviceAccount := corev1.ServiceAccount{}
        err := c.Get(ctx, types.NamespacedName{Namespace: parent.Namespace, Name: serviceAccountName}, &serviceAccount)
    
    After:
    
        serviceAccount := corev1.ServiceAccount{}
        err := c.TrackAndGet(ctx, types.NamespacedName{Namespace: parent.Namespace, Name: serviceAccountName}, &serviceAccount)
    
    The implementation assumes the ctx extends from a ParentReconciler.
    
    Signed-off-by: Scott Andrews <andrewssc@vmware.com>
    scothis committed May 9, 2022
    Copy the full SHA
    d5a278f View commit details
    Browse the repository at this point in the history