spiegel_podman/cmd/podman/system/migrate.go
Valentin Rothberg 8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00

65 lines
1.5 KiB
Go

// +build !remote
package system
import (
"fmt"
"os"
"github.com/containers/libpod/v2/cmd/podman/registry"
"github.com/containers/libpod/v2/cmd/podman/validate"
"github.com/containers/libpod/v2/pkg/domain/entities"
"github.com/containers/libpod/v2/pkg/domain/infra"
"github.com/spf13/cobra"
)
var (
migrateDescription = `
podman system migrate
Migrate existing containers to a new version of Podman.
`
migrateCommand = &cobra.Command{
Use: "migrate",
Args: validate.NoArgs,
Short: "Migrate containers",
Long: migrateDescription,
Run: migrate,
}
)
var (
migrateOptions entities.SystemMigrateOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: migrateCommand,
Parent: systemCmd,
})
flags := migrateCommand.Flags()
flags.StringVar(&migrateOptions.NewRuntime, "new-runtime", "", "Specify a new runtime for all containers")
}
func migrate(cmd *cobra.Command, args []string) {
// Shutdown all running engines, `renumber` will hijack repository
registry.ContainerEngine().Shutdown(registry.Context())
registry.ImageEngine().Shutdown(registry.Context())
engine, err := infra.NewSystemEngine(entities.MigrateMode, registry.PodmanConfig())
if err != nil {
fmt.Println(err)
os.Exit(125)
}
defer engine.Shutdown(registry.Context())
err = engine.Migrate(registry.Context(), cmd.Flags(), registry.PodmanConfig(), migrateOptions)
if err != nil {
fmt.Println(err)
os.Exit(125)
}
os.Exit(0)
}