timflannagan / rukpak

Rukpak runs in a Kubernetes cluster and defines an API for installing cloud native bundle content
Apache License 2.0
0 stars 0 forks source link

compare owner references vs. spec.Selector label selectors? #48

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 2 years ago

https://github.com/timflannagan/rukpak/blob/17e918c63e90db8c6b2d1f0eae21c497967b196c/internal/util/util.go#L57


func MapBundleToBundleInstanceHandler(cl client.Client, log logr.Logger) handler.MapFunc {
    return func(object client.Object) []reconcile.Request {
        b, ok := object.(*rukpakv1alpha1.Bundle)
        if !ok {
            return nil
        }
        bundleInstances := &rukpakv1alpha1.BundleInstanceList{}
        if err := cl.List(context.Background(), bundleInstances); err != nil {
            log.WithName("mapBundleToBundleInstanceHandler").Error(err, "list bundles")
            return nil
        }

        var requests []reconcile.Request
        for _, bi := range bundleInstances.Items {
            bi := bi
            // TODO: compare owner references vs. spec.Selector label selectors?
            for _, ref := range b.GetOwnerReferences() {
                if ref.Name == bi.GetName() {
                    requests = append(requests, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&bi)})
                }
            }
        }
        return requests
github-actions[bot] commented 2 years ago

Closed in 7bbdbf12679aff744ff6501e2ce7fcbf829b737c