(ctx *cu.Context, bldr *ctrl.Builder)
| 56 | } |
| 57 | |
| 58 | func (comp *migrationsComponent) Setup(ctx *cu.Context, bldr *ctrl.Builder) error { |
| 59 | bldr.Owns(&batchv1.Job{}) |
| 60 | bldr.Watches( |
| 61 | &source.Kind{Type: &corev1.Pod{}}, |
| 62 | handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request { |
| 63 | // Obj is a Pod that just got an event, map it back to any matching Migrators. |
| 64 | requests := []reconcile.Request{} |
| 65 | // Find any Migrator objects that match this pod. |
| 66 | migrators, err := utils.ListMatchingMigrators(context.Background(), ctx.Client, obj) |
| 67 | if err != nil { |
| 68 | ctx.Log.Error(err, "error listing matching migrators") |
| 69 | // TODO Metric to track this for alerting. |
| 70 | return requests |
| 71 | } |
| 72 | for _, migrator := range migrators { |
| 73 | requests = append(requests, reconcile.Request{ |
| 74 | NamespacedName: types.NamespacedName{ |
| 75 | Name: migrator.Name, |
| 76 | Namespace: migrator.Namespace, |
| 77 | }, |
| 78 | }) |
| 79 | } |
| 80 | return requests |
| 81 | }), |
| 82 | ) |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | func deepCopyJSON(src map[string]interface{}, dest map[string]interface{}) error { |
| 87 | if src == nil { |
no test coverage detected