(_ *cobra.Command, _ []string)
| 478 | } |
| 479 | |
| 480 | func (c *cmdMigrate) run(_ *cobra.Command, _ []string) error { |
| 481 | // Server |
| 482 | server, clientFingerprint, err := c.askServer() |
| 483 | if err != nil { |
| 484 | return err |
| 485 | } |
| 486 | |
| 487 | sigChan := make(chan os.Signal, 1) |
| 488 | signal.Notify(sigChan, os.Interrupt) |
| 489 | ctx, cancel := context.WithCancel(context.Background()) |
| 490 | |
| 491 | go func() { |
| 492 | <-sigChan |
| 493 | |
| 494 | if clientFingerprint != "" { |
| 495 | _ = server.DeleteCertificate(clientFingerprint) |
| 496 | } |
| 497 | |
| 498 | cancel() |
| 499 | |
| 500 | // The following nolint directive ignores the "deep-exit" rule of the revive linter. |
| 501 | // We should be exiting cleanly by passing the above context into each invoked method and checking for |
| 502 | // cancellation. Unfortunately our client methods do not accept a context argument. |
| 503 | os.Exit(1) //nolint:revive |
| 504 | }() |
| 505 | |
| 506 | if clientFingerprint != "" { |
| 507 | defer logger.WarnOnError(func() error { return server.DeleteCertificate(clientFingerprint) }, "Failed to delete certificate") |
| 508 | } |
| 509 | |
| 510 | // Provide migration type |
| 511 | creationType, err := c.global.asker.AskInt(` |
| 512 | What would you like to create? |
| 513 | 1) Container |
| 514 | 2) Virtual Machine |
| 515 | 3) Virtual Machine (from .ova) |
| 516 | 4) Custom Volume |
| 517 | |
| 518 | Please enter the number of your choice: `, 1, 4, "", nil) |
| 519 | if err != nil { |
| 520 | return err |
| 521 | } |
| 522 | |
| 523 | var migrator Migrator |
| 524 | switch creationType { |
| 525 | case 1: |
| 526 | migrator = newInstanceMigration(ctx, server, c.global.asker, c.flagRsyncArgs, MigrationTypeContainer) |
| 527 | case 2: |
| 528 | migrator = newInstanceMigration(ctx, server, c.global.asker, c.flagRsyncArgs, MigrationTypeVM) |
| 529 | case 3: |
| 530 | migrator = newOVAMigration(ctx, server, c.global.asker, c.flagRsyncArgs) |
| 531 | case 4: |
| 532 | migrator = newVolumeMigration(ctx, server, c.global.asker, c.flagRsyncArgs) |
| 533 | } |
| 534 | |
| 535 | err = migrator.gatherInfo() |
| 536 | if err != nil { |
| 537 | return err |
nothing calls this directly
no test coverage detected