summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/cliconfig/config.go1
-rw-r--r--cmd/podman/images.go16
-rw-r--r--cmd/podman/libpodruntime/runtime.go17
-rw-r--r--cmd/podman/system_migrate.go4
4 files changed, 21 insertions, 17 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index 5b5225f02..4831b7971 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -651,6 +651,7 @@ type SystemRenumberValues struct {
type SystemMigrateValues struct {
PodmanCommand
+ NewRuntime string
}
type SystemDfValues struct {
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index fe7c89b5c..e363fa3bb 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -216,17 +216,18 @@ func (i imagesOptions) setOutputFormat() string {
}
// imagesToGeneric creates an empty array of interfaces for output
-func imagesToGeneric(templParams []imagesTemplateParams, JSONParams []imagesJSONParams) (genericParams []interface{}) {
+func imagesToGeneric(templParams []imagesTemplateParams, JSONParams []imagesJSONParams) []interface{} {
+ genericParams := []interface{}{}
if len(templParams) > 0 {
for _, v := range templParams {
genericParams = append(genericParams, interface{}(v))
}
- return
+ return genericParams
}
for _, v := range JSONParams {
genericParams = append(genericParams, interface{}(v))
}
- return
+ return genericParams
}
func sortImagesOutput(sortBy string, imagesOutput imagesSorted) imagesSorted {
@@ -309,7 +310,8 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
}
// getImagesJSONOutput returns the images information in its raw form
-func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage) (imagesOutput []imagesJSONParams) {
+func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage) []imagesJSONParams {
+ imagesOutput := []imagesJSONParams{}
for _, img := range images {
size, err := img.Size(ctx)
if err != nil {
@@ -325,7 +327,7 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
}
imagesOutput = append(imagesOutput, params)
}
- return
+ return imagesOutput
}
// generateImagesOutput generates the images based on the format provided
@@ -336,10 +338,6 @@ func generateImagesOutput(ctx context.Context, images []*adapter.ContainerImage,
switch opts.format {
case formats.JSONString:
- // If 0 images are present, print nothing for JSON
- if len(images) == 0 {
- return nil
- }
imagesOutput := getImagesJSONOutput(ctx, images)
out = formats.JSONStructArray{Output: imagesToGeneric([]imagesTemplateParams{}, imagesOutput)}
default:
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index 6dafeb0b0..dd8c3f173 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -14,31 +14,31 @@ import (
)
// 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, false, true)
+func GetRuntimeMigrate(ctx context.Context, c *cliconfig.PodmanCommand, newRuntime string) (*libpod.Runtime, error) {
+ return getRuntime(ctx, c, false, true, false, true, newRuntime)
}
// GetRuntimeDisableFDs gets a libpod runtime that will disable sd notify
func GetRuntimeDisableFDs(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, false, false, false, false)
+ return getRuntime(ctx, c, false, false, false, false, "")
}
// GetRuntimeRenumber gets a libpod runtime that will perform a lock renumber
func GetRuntimeRenumber(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, true, false, false, true)
+ return getRuntime(ctx, c, true, false, false, true, "")
}
// GetRuntime generates a new libpod runtime configured by command line options
func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, false, false, false, true)
+ return getRuntime(ctx, c, false, false, false, true, "")
}
// GetRuntimeNoStore generates a new libpod runtime configured by command line options
func GetRuntimeNoStore(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, false, false, true, true)
+ return getRuntime(ctx, c, false, false, true, true, "")
}
-func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migrate, noStore, withFDS bool) (*libpod.Runtime, error) {
+func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migrate, noStore, withFDS bool, newRuntime string) (*libpod.Runtime, error) {
options := []libpod.RuntimeOption{}
storageOpts := storage.StoreOptions{}
storageSet := false
@@ -88,6 +88,9 @@ func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migra
}
if migrate {
options = append(options, libpod.WithMigrate())
+ if newRuntime != "" {
+ options = append(options, libpod.WithMigrateRuntime(newRuntime))
+ }
}
if renumber {
diff --git a/cmd/podman/system_migrate.go b/cmd/podman/system_migrate.go
index 4a0afcfad..9c90aeb52 100644
--- a/cmd/podman/system_migrate.go
+++ b/cmd/podman/system_migrate.go
@@ -32,13 +32,15 @@ func init() {
migrateCommand.Command = _migrateCommand
migrateCommand.SetHelpTemplate(HelpTemplate())
migrateCommand.SetUsageTemplate(UsageTemplate())
+ flags := migrateCommand.Flags()
+ flags.StringVar(&migrateCommand.NewRuntime, "new-runtime", "", "Specify a new runtime for all containers")
}
func migrateCmd(c *cliconfig.SystemMigrateValues) error {
// We need to pass one extra option to NewRuntime.
// This will inform the OCI runtime to start a migrate.
// That's controlled by the last argument to GetRuntime.
- r, err := libpodruntime.GetRuntimeMigrate(getContext(), &c.PodmanCommand)
+ r, err := libpodruntime.GetRuntimeMigrate(getContext(), &c.PodmanCommand, c.NewRuntime)
if err != nil {
return errors.Wrapf(err, "error migrating containers")
}