| 48 | } |
| 49 | |
| 50 | func (h *readyHandler) handle(w http.ResponseWriter, r *http.Request) (bool, error) { |
| 51 | // Parse args. |
| 52 | var args ReadyArgs |
| 53 | err := json.NewDecoder(r.Body).Decode(&args) |
| 54 | if err != nil { |
| 55 | return false, err |
| 56 | } |
| 57 | |
| 58 | // Try to find the migrator object. |
| 59 | migrator := &migrationsv1beta1.Migrator{} |
| 60 | err = h.client.Get(r.Context(), types.NamespacedName{Name: args.MigratorName, Namespace: args.MigratorNamespace}, migrator) |
| 61 | if err != nil { |
| 62 | if kerrors.IsNotFound(err) { |
| 63 | return false, nil |
| 64 | } else { |
| 65 | return false, err |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // Check if the version matches. |
| 70 | return migrator.Status.LastSuccessfulMigration == args.TargetImage, nil |
| 71 | } |