clusterMatchesPod returns true if any of the cluster's podSelectorRefs match the given pod's labels.
(cluster *apiv1.Cluster, pod *corev1.Pod)
| 36 | // clusterMatchesPod returns true if any of the cluster's podSelectorRefs |
| 37 | // match the given pod's labels. |
| 38 | func clusterMatchesPod(cluster *apiv1.Cluster, pod *corev1.Pod) bool { |
| 39 | for i := range cluster.Spec.PodSelectorRefs { |
| 40 | ref := &cluster.Spec.PodSelectorRefs[i] |
| 41 | selector, err := metav1.LabelSelectorAsSelector(&ref.Selector) |
| 42 | if err != nil { |
| 43 | continue |
| 44 | } |
| 45 | if selector.Matches(labels.Set(pod.Labels)) { |
| 46 | return true |
| 47 | } |
| 48 | } |
| 49 | return false |
| 50 | } |
| 51 | |
| 52 | // MapExternalPodsToClusters returns a handler that maps pod events to |
| 53 | // Cluster reconcile requests when the pod matches any Cluster's podSelectorRefs. |
no test coverage detected