(ctx context.Context, c client.Client, pod metav1.Object)
| 28 | ) |
| 29 | |
| 30 | func ListMatchingMigrators(ctx context.Context, c client.Client, pod metav1.Object) ([]*migrationsv1beta1.Migrator, error) { |
| 31 | // Find any Migrator objects that match this pod. |
| 32 | allMigrators := &migrationsv1beta1.MigratorList{} |
| 33 | err := c.List(ctx, allMigrators, &client.ListOptions{Namespace: pod.GetNamespace()}) |
| 34 | if err != nil { |
| 35 | return nil, errors.Wrapf(err, "error listing migrators in %s", pod.GetNamespace()) |
| 36 | } |
| 37 | migrators := []*migrationsv1beta1.Migrator{} |
| 38 | podLabels := labels.Set(pod.GetLabels()) |
| 39 | for _, m := range allMigrators.Items { |
| 40 | selector, err := metav1.LabelSelectorAsSelector(m.Spec.Selector) |
| 41 | if err != nil { |
| 42 | // Ignore this migrator. Maybe print a warning in the future? This should probably be handled via a validator on Migrator. |
| 43 | continue |
| 44 | } |
| 45 | if selector.Matches(podLabels) { |
| 46 | migrator := m |
| 47 | migrators = append(migrators, &migrator) |
| 48 | } |
| 49 | } |
| 50 | return migrators, nil |
| 51 | } |
no outgoing calls
no test coverage detected