diff options
Diffstat (limited to 'cmd/podman/libpodruntime/runtime.go')
-rw-r--r-- | cmd/podman/libpodruntime/runtime.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go index 78adf1252..b03846bbc 100644 --- a/cmd/podman/libpodruntime/runtime.go +++ b/cmd/podman/libpodruntime/runtime.go @@ -1,6 +1,8 @@ package libpodruntime import ( + "context" + "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/rootless" @@ -9,17 +11,22 @@ import ( "github.com/pkg/errors" ) +// GetRuntimeMigrate gets a libpod runtime that will perform a migration of existing containers +func GetRuntimeMigrate(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) { + return getRuntime(ctx, c, false, true) +} + // GetRuntimeRenumber gets a libpod runtime that will perform a lock renumber -func GetRuntimeRenumber(c *cliconfig.PodmanCommand) (*libpod.Runtime, error) { - return getRuntime(c, true) +func GetRuntimeRenumber(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) { + return getRuntime(ctx, c, true, false) } // GetRuntime generates a new libpod runtime configured by command line options -func GetRuntime(c *cliconfig.PodmanCommand) (*libpod.Runtime, error) { - return getRuntime(c, false) +func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) { + return getRuntime(ctx, c, false, false) } -func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, error) { +func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool, migrate bool) (*libpod.Runtime, error) { options := []libpod.RuntimeOption{} storageOpts := storage.StoreOptions{} storageSet := false @@ -63,11 +70,16 @@ func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, err storageSet = true storageOpts.GraphDriverOptions = c.GlobalFlags.StorageOpts } + if migrate { + options = append(options, libpod.WithMigrate()) + } if renumber { options = append(options, libpod.WithRenumber()) } + options = append(options, libpod.WithContext(ctx)) + // Only set this if the user changes storage config on the command line if storageSet { options = append(options, libpod.WithStorageConfig(storageOpts)) |