MCPcopy Index your code
hub / github.com/coderanger/migrations-operator / Setup

Method Setup

components/migrations.go:58–84  ·  view source on GitHub ↗
(ctx *cu.Context, bldr *ctrl.Builder)

Source from the content-addressed store, hash-verified

56}
57
58func (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
86func deepCopyJSON(src map[string]interface{}, dest map[string]interface{}) error {
87 if src == nil {

Callers 1

migrations_test.goFile · 0.80

Calls 1

ListMatchingMigratorsFunction · 0.92

Tested by

no test coverage detected