diff options
Diffstat (limited to 'cmd/podman')
86 files changed, 175 insertions, 233 deletions
diff --git a/cmd/podman/attach.go b/cmd/podman/attach.go index c07c0f1cf..37f8afbad 100644 --- a/cmd/podman/attach.go +++ b/cmd/podman/attach.go @@ -47,7 +47,7 @@ func attachCmd(c *cliconfig.AttachValues) error { if remoteclient && len(c.InputArgs) != 1 { return errors.Errorf("attach requires the name or id of one running container") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating runtime") } diff --git a/cmd/podman/build.go b/cmd/podman/build.go index b69ac6e84..647ff1e86 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -206,7 +206,7 @@ func buildCmd(c *cliconfig.BuildValues) error { dockerfiles = append(dockerfiles, filepath.Join(contextDir, "Dockerfile")) } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go index f2f5d37da..234d683bb 100644 --- a/cmd/podman/checkpoint.go +++ b/cmd/podman/checkpoint.go @@ -54,7 +54,7 @@ func checkpointCmd(c *cliconfig.CheckpointValues) error { return errors.New("checkpointing a container requires root") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/cleanup.go b/cmd/podman/cleanup.go index f5b3cf55b..9434c68ba 100644 --- a/cmd/podman/cleanup.go +++ b/cmd/podman/cleanup.go @@ -49,7 +49,7 @@ func init() { } func cleanupCmd(c *cliconfig.CleanupValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go index 640a4bff4..77156f47a 100644 --- a/cmd/podman/cliconfig/config.go +++ b/cmd/podman/cliconfig/config.go @@ -581,6 +581,10 @@ type SystemRenumberValues struct { PodmanCommand } +type SystemMigrateValues struct { + PodmanCommand +} + type SystemDfValues struct { PodmanCommand Verbose bool diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go index 7680d6df2..36c28696f 100644 --- a/cmd/podman/commands.go +++ b/cmd/podman/commands.go @@ -21,7 +21,6 @@ func getMainCommands() []*cobra.Command { _refreshCommand, _searchCommand, _statsCommand, - _topCommand, } if len(_varlinkCommand.Use) > 0 { @@ -53,7 +52,6 @@ func getContainerSubCommands() []*cobra.Command { _runlabelCommand, _statsCommand, _stopCommand, - _topCommand, _umountCommand, } } @@ -79,6 +77,7 @@ func getSystemSubCommands() []*cobra.Command { _pruneSystemCommand, _renumberCommand, _dfSystemCommand, + _migrateCommand, } } diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go index 8d79c1e28..2b38bab35 100644 --- a/cmd/podman/commit.go +++ b/cmd/podman/commit.go @@ -52,7 +52,7 @@ func init() { } func commitCmd(c *cliconfig.CommitValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/common.go b/cmd/podman/common.go index ba4a3f519..eac96d3ba 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -434,6 +434,10 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "read-only", false, "Make containers root filesystem read-only", ) + createFlags.Bool( + "read-only-tmpfs", true, + "When running containers in read-only mode mount a read-write tmpfs on /run, /tmp and /var/tmp", + ) createFlags.String( "restart", "", "Restart is not supported. Please use a systemd unit file for restart", diff --git a/cmd/podman/container.go b/cmd/podman/container.go index 28e0f0e4a..52152d50e 100644 --- a/cmd/podman/container.go +++ b/cmd/podman/container.go @@ -64,6 +64,7 @@ var ( _runCommand, _rmCommand, _startCommand, + _topCommand, _unpauseCommand, _waitCommand, } diff --git a/cmd/podman/containers_prune.go b/cmd/podman/containers_prune.go index abc56cee1..8270669c9 100644 --- a/cmd/podman/containers_prune.go +++ b/cmd/podman/containers_prune.go @@ -75,7 +75,7 @@ func pruneContainers(runtime *adapter.LocalRuntime, ctx context.Context, maxWork } func pruneContainersCmd(c *cliconfig.PruneContainersValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go index 6e48b9f3b..82f2d3f20 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -58,7 +58,7 @@ func cpCmd(c *cliconfig.CpValues) error { return errors.Errorf("you must provide a source path and a destination path") } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/create.go b/cmd/podman/create.go index cfc0fa0c3..cb3ba14c5 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -52,7 +52,7 @@ func createCmd(c *cliconfig.CreateValues) error { return err } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go index 1138c48a3..9543113d8 100644 --- a/cmd/podman/diff.go +++ b/cmd/podman/diff.go @@ -87,7 +87,7 @@ func diffCmd(c *cliconfig.DiffValues) error { return errors.Errorf("container, image, or layer name must be specified: podman diff [options [...]] ID-NAME") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/events.go b/cmd/podman/events.go index 4c11fe1f3..15f5e9571 100644 --- a/cmd/podman/events.go +++ b/cmd/podman/events.go @@ -40,7 +40,7 @@ func init() { } func eventsCmd(c *cliconfig.EventValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go index d0d88ee8b..deff44a92 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -68,7 +68,7 @@ func execCmd(c *cliconfig.ExecValues) error { argStart = 0 } cmd := args[argStart:] - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go index dae48f14b..6619522b6 100644 --- a/cmd/podman/exists.go +++ b/cmd/podman/exists.go @@ -86,7 +86,7 @@ func imageExistsCmd(c *cliconfig.ImageExistsValues) error { if len(args) > 1 || len(args) < 1 { return errors.New("you may only check for the existence of one image at a time") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } @@ -107,7 +107,7 @@ func containerExistsCmd(c *cliconfig.ContainerExistsValues) error { if len(args) > 1 || len(args) < 1 { return errors.New("you may only check for the existence of one container at a time") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } @@ -126,7 +126,7 @@ func podExistsCmd(c *cliconfig.PodExistsValues) error { if len(args) > 1 || len(args) < 1 { return errors.New("you may only check for the existence of one pod at a time") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/export.go b/cmd/podman/export.go index 004c3ccde..82a4c13e7 100644 --- a/cmd/podman/export.go +++ b/cmd/podman/export.go @@ -41,7 +41,7 @@ func init() { // exportCmd saves a container to a tarball on disk func exportCmd(c *cliconfig.ExportValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/generate_kube.go b/cmd/podman/generate_kube.go index 7963cde6e..318dd0771 100644 --- a/cmd/podman/generate_kube.go +++ b/cmd/podman/generate_kube.go @@ -54,7 +54,7 @@ func generateKubeYAMLCmd(c *cliconfig.GenerateKubeValues) error { return errors.Errorf("you must provide exactly one container|pod ID or name") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/healthcheck_run.go b/cmd/podman/healthcheck_run.go index 832451e0c..111318d9c 100644 --- a/cmd/podman/healthcheck_run.go +++ b/cmd/podman/healthcheck_run.go @@ -38,7 +38,7 @@ func init() { } func healthCheckCmd(c *cliconfig.HealthCheckValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrap(err, "could not get runtime") } diff --git a/cmd/podman/history.go b/cmd/podman/history.go index f96d7934c..cebf99a9f 100644 --- a/cmd/podman/history.go +++ b/cmd/podman/history.go @@ -67,7 +67,7 @@ func init() { } func historyCmd(c *cliconfig.HistoryValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/images.go b/cmd/podman/images.go index f584c1131..1c46571c3 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -134,7 +134,7 @@ func imagesCmd(c *cliconfig.ImagesValues) error { image string ) - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "Could not get runtime") } @@ -243,7 +243,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma // If all is false and the image doesn't have a name, check to see if the top layer of the image is a parent // to another image's top layer. If it is, then it is an intermediate image so don't print out if the --all flag // is not set. - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { logrus.Errorf("error checking if image is a parent %q: %v", img.ID(), err) } diff --git a/cmd/podman/images_prune.go b/cmd/podman/images_prune.go index 84181d0a2..1ac5bc65d 100644 --- a/cmd/podman/images_prune.go +++ b/cmd/podman/images_prune.go @@ -37,7 +37,7 @@ func init() { } func pruneImagesCmd(c *cliconfig.PruneImagesValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } @@ -45,7 +45,7 @@ func pruneImagesCmd(c *cliconfig.PruneImagesValues) error { // Call prune; if any cids are returned, print them and then // return err in case an error also came up - pruneCids, err := runtime.PruneImages(c.All) + pruneCids, err := runtime.PruneImages(getContext(), c.All) if len(pruneCids) > 0 { for _, cid := range pruneCids { fmt.Println(cid) diff --git a/cmd/podman/import.go b/cmd/podman/import.go index 2bba6cb0c..167d9f2c9 100644 --- a/cmd/podman/import.go +++ b/cmd/podman/import.go @@ -45,7 +45,7 @@ func init() { } func importCmd(c *cliconfig.ImportValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/info.go b/cmd/podman/info.go index 2b6ae1882..a6fce7fcb 100644 --- a/cmd/podman/info.go +++ b/cmd/podman/info.go @@ -50,7 +50,7 @@ func infoCmd(c *cliconfig.InfoValues) error { info := map[string]interface{}{} remoteClientInfo := map[string]interface{}{} - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 9491bc7c7..4303c149c 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -84,7 +84,7 @@ func inspectCmd(c *cliconfig.InspectValues) error { return errors.Errorf("you cannot provide additional arguments with --latest") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/kill.go b/cmd/podman/kill.go index 0513a154f..edf69ff2e 100644 --- a/cmd/podman/kill.go +++ b/cmd/podman/kill.go @@ -59,7 +59,7 @@ func killCmd(c *cliconfig.KillValues) error { return err } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } 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)) diff --git a/cmd/podman/load.go b/cmd/podman/load.go index 3cc5e67c7..f3bbed48f 100644 --- a/cmd/podman/load.go +++ b/cmd/podman/load.go @@ -58,7 +58,7 @@ func loadCmd(c *cliconfig.LoadValues) error { return errors.New("too many arguments. Requires exactly 1") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go index 6f24dc8fb..a1ec9f4ee 100644 --- a/cmd/podman/logs.go +++ b/cmd/podman/logs.go @@ -64,7 +64,7 @@ func init() { func logsCmd(c *cliconfig.LogsValues) error { var err error - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 392dfe542..a0f1cf401 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -57,6 +57,7 @@ var mainCommands = []*cobra.Command{ _saveCommand, _stopCommand, _tagCommand, + _topCommand, _umountCommand, _unpauseCommand, _versionCommand, diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go index 91ad42630..5afd51e28 100644 --- a/cmd/podman/main_local.go +++ b/cmd/podman/main_local.go @@ -103,7 +103,7 @@ func profileOff(cmd *cobra.Command) error { } func setupRootless(cmd *cobra.Command, args []string) error { - if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || cmd == _mountCommand || strings.HasPrefix(cmd.Use, "help") { + if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || cmd == _mountCommand || cmd == _migrateCommand || strings.HasPrefix(cmd.Use, "help") { return nil } podmanCmd := cliconfig.PodmanCommand{ @@ -112,7 +112,7 @@ func setupRootless(cmd *cobra.Command, args []string) error { MainGlobalOpts, remoteclient, } - runtime, err := libpodruntime.GetRuntime(&podmanCmd) + runtime, err := libpodruntime.GetRuntime(getContext(), &podmanCmd) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/mount.go b/cmd/podman/mount.go index 2ade8949a..7c9150d1b 100644 --- a/cmd/podman/mount.go +++ b/cmd/podman/mount.go @@ -61,7 +61,7 @@ type jsonMountPoint struct { } func mountCmd(c *cliconfig.MountValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pause.go b/cmd/podman/pause.go index ca137150a..cd8370082 100644 --- a/cmd/podman/pause.go +++ b/cmd/podman/pause.go @@ -43,7 +43,7 @@ func pauseCmd(c *cliconfig.PauseValues) error { return errors.New("pause is not supported for rootless containers") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go index d1008e615..967798399 100644 --- a/cmd/podman/play_kube.go +++ b/cmd/podman/play_kube.go @@ -75,7 +75,7 @@ func playKubeCmd(c *cliconfig.KubePlayValues) error { } ctx := getContext() - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(ctx, &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_create.go b/cmd/podman/pod_create.go index 551010dce..c891f2c7b 100644 --- a/cmd/podman/pod_create.go +++ b/cmd/podman/pod_create.go @@ -62,7 +62,7 @@ func podCreateCmd(c *cliconfig.PodCreateValues) error { podIdFile *os.File ) - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go index eb2366031..a22624078 100644 --- a/cmd/podman/pod_inspect.go +++ b/cmd/podman/pod_inspect.go @@ -49,7 +49,7 @@ func podInspectCmd(c *cliconfig.PodInspectValues) error { return errors.Errorf("you must provide the name or id of a pod") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_kill.go b/cmd/podman/pod_kill.go index 145d0492f..c1ea66126 100644 --- a/cmd/podman/pod_kill.go +++ b/cmd/podman/pod_kill.go @@ -49,7 +49,7 @@ func init() { // podKillCmd kills one or more pods with a signal func podKillCmd(c *cliconfig.PodKillValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_pause.go b/cmd/podman/pod_pause.go index 1c6611ebc..e8574bfdc 100644 --- a/cmd/podman/pod_pause.go +++ b/cmd/podman/pod_pause.go @@ -45,7 +45,7 @@ func init() { func podPauseCmd(c *cliconfig.PodPauseValues) error { var lastError error - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go index f4b7437eb..b9dcbc05d 100644 --- a/cmd/podman/pod_ps.go +++ b/cmd/podman/pod_ps.go @@ -157,7 +157,7 @@ func podPsCmd(c *cliconfig.PodPsValues) error { return errors.Wrapf(err, "error with flags passed") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pod_restart.go b/cmd/podman/pod_restart.go index 519568974..a1f4c8359 100644 --- a/cmd/podman/pod_restart.go +++ b/cmd/podman/pod_restart.go @@ -47,7 +47,7 @@ func init() { func podRestartCmd(c *cliconfig.PodRestartValues) error { var lastError error - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go index dd67bb0e0..218ed8154 100644 --- a/cmd/podman/pod_rm.go +++ b/cmd/podman/pod_rm.go @@ -47,7 +47,7 @@ func init() { // podRmCmd deletes pods func podRmCmd(c *cliconfig.PodRmValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_start.go b/cmd/podman/pod_start.go index 104f9ad73..5c9225428 100644 --- a/cmd/podman/pod_start.go +++ b/cmd/podman/pod_start.go @@ -45,7 +45,7 @@ func init() { } func podStartCmd(c *cliconfig.PodStartValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go index ed59d9a61..e0e5ca24e 100644 --- a/cmd/podman/pod_stats.go +++ b/cmd/podman/pod_stats.go @@ -78,7 +78,7 @@ func podStatsCmd(c *cliconfig.PodStatsValues) error { all = true } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_stop.go b/cmd/podman/pod_stop.go index 9cd425c29..b4b1718d9 100644 --- a/cmd/podman/pod_stop.go +++ b/cmd/podman/pod_stop.go @@ -47,7 +47,7 @@ func init() { } func podStopCmd(c *cliconfig.PodStopValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go index e997d1456..64e32318e 100644 --- a/cmd/podman/pod_top.go +++ b/cmd/podman/pod_top.go @@ -67,7 +67,7 @@ func podTopCmd(c *cliconfig.PodTopValues) error { return errors.Errorf("you must provide the name or id of a running pod") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pod_unpause.go b/cmd/podman/pod_unpause.go index 15375bee9..c5b7e6a18 100644 --- a/cmd/podman/pod_unpause.go +++ b/cmd/podman/pod_unpause.go @@ -46,7 +46,7 @@ func init() { func podUnpauseCmd(c *cliconfig.PodUnpauseValues) error { var lastError error - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pods_prune.go b/cmd/podman/pods_prune.go index e6946f068..bdd75f9de 100644 --- a/cmd/podman/pods_prune.go +++ b/cmd/podman/pods_prune.go @@ -36,7 +36,7 @@ func init() { } func podPruneCmd(c *cliconfig.PodPruneValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/port.go b/cmd/podman/port.go index d63ae4aa9..7a9f01fe6 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -98,7 +98,7 @@ func portCmd(c *cliconfig.PortValues) error { } } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index df1ea2765..623f17050 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -211,7 +211,7 @@ func psCmd(c *cliconfig.PsValues) error { return errors.Wrapf(err, "error with flags passed") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go index 521419e7a..f6a5beb17 100644 --- a/cmd/podman/pull.go +++ b/cmd/podman/pull.go @@ -73,7 +73,7 @@ func pullCmd(c *cliconfig.PullValues) (retError error) { defer span.Finish() } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") diff --git a/cmd/podman/push.go b/cmd/podman/push.go index e6beaaeb4..ee14b15e2 100644 --- a/cmd/podman/push.go +++ b/cmd/podman/push.go @@ -100,7 +100,7 @@ func pushCmd(c *cliconfig.PushValues) error { registryCreds = creds } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index 6640d9954..9f9cbf908 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -38,7 +38,7 @@ func init() { } func refreshCmd(c *cliconfig.RefreshValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go index 9ab2dd528..437676eef 100644 --- a/cmd/podman/restart.go +++ b/cmd/podman/restart.go @@ -51,7 +51,7 @@ func restartCmd(c *cliconfig.RestartValues) error { return errors.Wrapf(libpod.ErrInvalidArg, "you must provide at least one container name or ID") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index d9e85c267..8cfd5ca0d 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -54,7 +54,7 @@ func restoreCmd(c *cliconfig.RestoreValues) error { return errors.New("restoring a container requires root") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index e3ee186ce..1bf56b782 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -48,7 +48,7 @@ func init() { // rmCmd removes one or more containers func rmCmd(c *cliconfig.RmValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index 7ec875d5b..4c41a3ad5 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -51,7 +51,7 @@ func rmiCmd(c *cliconfig.RmiValues) error { ctx := getContext() removeAll := c.All - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } @@ -97,7 +97,7 @@ func rmiCmd(c *cliconfig.RmiValues) error { return errors.New("unable to delete all images; re-run the rmi command again.") } for _, i := range imagesToDelete { - isParent, err := i.IsParent() + isParent, err := i.IsParent(ctx) if err != nil { return err } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 717a36e04..01b12d282 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -48,7 +48,7 @@ func runCmd(c *cliconfig.RunValues) error { return err } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/runlabel.go b/cmd/podman/runlabel.go index 8267e941f..f097cb693 100644 --- a/cmd/podman/runlabel.go +++ b/cmd/podman/runlabel.go @@ -85,7 +85,7 @@ func runlabelCmd(c *cliconfig.RunlabelValues) error { } opts := make(map[string]string) - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/save.go b/cmd/podman/save.go index a45223b6a..4d204337e 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -70,7 +70,7 @@ func saveCmd(c *cliconfig.SaveValues) error { return errors.Errorf("need at least 1 argument") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go index e14276bdf..9050fd2b9 100644 --- a/cmd/podman/shared/container.go +++ b/cmd/podman/shared/container.go @@ -658,7 +658,8 @@ func GetCtrInspectInfo(config *libpod.ContainerConfig, ctrInspectData *inspect.C OomKillDisable: memDisableOOMKiller, PidsLimit: pidsLimit, Privileged: config.Privileged, - ReadonlyRootfs: spec.Root.Readonly, + ReadOnlyRootfs: spec.Root.Readonly, + ReadOnlyTmpfs: createArtifact.ReadOnlyTmpfs, Runtime: config.OCIRuntime, NetworkMode: string(createArtifact.NetMode), IpcMode: string(createArtifact.IpcMode), diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 3f54e193f..c521f9cb6 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -650,6 +650,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. PortBindings: portBindings, Quiet: c.Bool("quiet"), ReadOnlyRootfs: c.Bool("read-only"), + ReadOnlyTmpfs: c.Bool("read-only-tmpfs"), Resources: cc.CreateResourceConfig{ BlkioWeight: blkioWeight, BlkioWeightDevice: c.StringSlice("blkio-weight-device"), diff --git a/cmd/podman/shared/events.go b/cmd/podman/shared/events.go deleted file mode 100644 index c62044271..000000000 --- a/cmd/podman/shared/events.go +++ /dev/null @@ -1,115 +0,0 @@ -package shared - -import ( - "fmt" - "strings" - "time" - - "github.com/containers/libpod/libpod/events" - "github.com/containers/libpod/pkg/util" - "github.com/pkg/errors" -) - -func generateEventFilter(filter, filterValue string) (func(e *events.Event) bool, error) { - switch strings.ToUpper(filter) { - case "CONTAINER": - return func(e *events.Event) bool { - if e.Type != events.Container { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "EVENT", "STATUS": - return func(e *events.Event) bool { - return fmt.Sprintf("%s", e.Status) == filterValue - }, nil - case "IMAGE": - return func(e *events.Event) bool { - if e.Type != events.Image { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "POD": - return func(e *events.Event) bool { - if e.Type != events.Pod { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "VOLUME": - return func(e *events.Event) bool { - if e.Type != events.Volume { - return false - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "TYPE": - return func(e *events.Event) bool { - return fmt.Sprintf("%s", e.Type) == filterValue - }, nil - } - return nil, errors.Errorf("%s is an invalid filter", filter) -} - -func generateEventSinceOption(timeSince time.Time) func(e *events.Event) bool { - return func(e *events.Event) bool { - return e.Time.After(timeSince) - } -} - -func generateEventUntilOption(timeUntil time.Time) func(e *events.Event) bool { - return func(e *events.Event) bool { - return e.Time.Before(timeUntil) - - } -} - -func parseFilter(filter string) (string, string, error) { - filterSplit := strings.Split(filter, "=") - if len(filterSplit) != 2 { - return "", "", errors.Errorf("%s is an invalid filter", filter) - } - return filterSplit[0], filterSplit[1], nil -} - -func GenerateEventOptions(filters []string, since, until string) ([]events.EventFilter, error) { - var options []events.EventFilter - for _, filter := range filters { - key, val, err := parseFilter(filter) - if err != nil { - return nil, err - } - funcFilter, err := generateEventFilter(key, val) - if err != nil { - return nil, err - } - options = append(options, funcFilter) - } - - if len(since) > 0 { - timeSince, err := util.ParseInputTime(since) - if err != nil { - return nil, errors.Wrapf(err, "unable to convert since time of %s", since) - } - options = append(options, generateEventSinceOption(timeSince)) - } - - if len(until) > 0 { - timeUntil, err := util.ParseInputTime(until) - if err != nil { - return nil, errors.Wrapf(err, "unable to convert until time of %s", until) - } - options = append(options, generateEventUntilOption(timeUntil)) - } - return options, nil -} diff --git a/cmd/podman/shared/intermediate.go b/cmd/podman/shared/intermediate.go index 2e1827561..9c494dec5 100644 --- a/cmd/podman/shared/intermediate.go +++ b/cmd/podman/shared/intermediate.go @@ -434,6 +434,7 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes m["publish-all"] = newCRBool(c, "publish-all") m["quiet"] = newCRBool(c, "quiet") m["read-only"] = newCRBool(c, "read-only") + m["read-only-tmpfs"] = newCRBool(c, "read-only-tmpfs") m["restart"] = newCRString(c, "restart") m["rm"] = newCRBool(c, "rm") m["rootfs"] = newCRBool(c, "rootfs") diff --git a/cmd/podman/shared/intermediate_varlink.go b/cmd/podman/shared/intermediate_varlink.go index d62a65955..5e21245e3 100644 --- a/cmd/podman/shared/intermediate_varlink.go +++ b/cmd/podman/shared/intermediate_varlink.go @@ -141,6 +141,7 @@ func (g GenericCLIResults) MakeVarlink() iopodman.Create { PublishAll: BoolToPtr(g.Find("publish-all")), Quiet: BoolToPtr(g.Find("quiet")), Readonly: BoolToPtr(g.Find("read-only")), + Readonlytmpfs: BoolToPtr(g.Find("read-only-tmpfs")), Restart: StringToPtr(g.Find("restart")), Rm: BoolToPtr(g.Find("rm")), Rootfs: BoolToPtr(g.Find("rootfs")), @@ -397,6 +398,7 @@ func VarlinkCreateToGeneric(opts iopodman.Create) GenericCLIResults { m["publish-all"] = boolFromVarlink(opts.PublishAll, "publish-all", false) m["quiet"] = boolFromVarlink(opts.Quiet, "quiet", false) m["read-only"] = boolFromVarlink(opts.Readonly, "read-only", false) + m["read-only-tmpfs"] = boolFromVarlink(opts.Readonlytmpfs, "read-only-tmpfs", true) m["restart"] = stringFromVarlink(opts.Restart, "restart", nil) m["rm"] = boolFromVarlink(opts.Rm, "rm", false) m["rootfs"] = boolFromVarlink(opts.Rootfs, "rootfs", false) diff --git a/cmd/podman/sign.go b/cmd/podman/sign.go index b19b6a840..0c25eec62 100644 --- a/cmd/podman/sign.go +++ b/cmd/podman/sign.go @@ -56,7 +56,7 @@ func signCmd(c *cliconfig.SignValues) error { if len(args) < 1 { return errors.Errorf("at least one image name must be specified") } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 9f93061f9..bd34010f2 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -65,7 +65,7 @@ func startCmd(c *cliconfig.StartValues) error { return errors.Wrapf(libpod.ErrInvalidArg, "you cannot use sig-proxy without --attach") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go index 6aa0cc10c..c2b2a688c 100644 --- a/cmd/podman/stats.go +++ b/cmd/podman/stats.go @@ -88,7 +88,7 @@ func statsCmd(c *cliconfig.StatsValues) error { return errors.Errorf("you must specify --all, --latest, or at least one container") } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index f263bb166..d88c90deb 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -56,7 +56,7 @@ func stopCmd(c *cliconfig.StopValues) error { defer span.Finish() } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go index 16a8ad120..840916547 100644 --- a/cmd/podman/system_df.go +++ b/cmd/podman/system_df.go @@ -99,7 +99,7 @@ func init() { } func dfSystemCmd(c *cliconfig.SystemDfValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "Could not get runtime") } @@ -201,7 +201,7 @@ func imageUniqueSize(ctx context.Context, images []*image.Image) (map[string]uin for _, img := range images { parentImg := img for { - next, err := parentImg.GetParent() + next, err := parentImg.GetParent(ctx) if err != nil { return nil, errors.Wrapf(err, "error getting parent of image %s", parentImg.ID()) } @@ -246,11 +246,11 @@ func getImageDiskUsage(ctx context.Context, images []*image.Image, imageUsedbyCi unreclaimableSize += imageUsedSize(img, imgUniqueSizeMap, imageUsedbyCintainerMap, imageUsedbyActiveContainerMap) - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { return imageDiskUsage, err } - parent, err := img.GetParent() + parent, err := img.GetParent(ctx) if err != nil { return imageDiskUsage, errors.Wrapf(err, "error getting parent of image %s", img.ID()) } @@ -437,11 +437,11 @@ func getImageVerboseDiskUsage(ctx context.Context, images []*image.Image, images return imagesVerboseDiskUsage, errors.Wrapf(err, "error getting unique size of images") } for _, img := range images { - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { return imagesVerboseDiskUsage, errors.Wrapf(err, "error checking if %s is a parent images", img.ID()) } - parent, err := img.GetParent() + parent, err := img.GetParent(ctx) if err != nil { return imagesVerboseDiskUsage, errors.Wrapf(err, "error getting parent of image %s", img.ID()) } diff --git a/cmd/podman/system_migrate.go b/cmd/podman/system_migrate.go new file mode 100644 index 000000000..4a0afcfad --- /dev/null +++ b/cmd/podman/system_migrate.go @@ -0,0 +1,50 @@ +package main + +import ( + "github.com/containers/libpod/cmd/podman/cliconfig" + "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +var ( + migrateCommand cliconfig.SystemMigrateValues + migrateDescription = ` + podman system migrate + + Migrate existing containers to a new version of Podman. +` + + _migrateCommand = &cobra.Command{ + Use: "migrate", + Args: noSubArgs, + Short: "Migrate containers", + Long: migrateDescription, + RunE: func(cmd *cobra.Command, args []string) error { + migrateCommand.InputArgs = args + migrateCommand.GlobalFlags = MainGlobalOpts + return migrateCmd(&migrateCommand) + }, + } +) + +func init() { + migrateCommand.Command = _migrateCommand + migrateCommand.SetHelpTemplate(HelpTemplate()) + migrateCommand.SetUsageTemplate(UsageTemplate()) +} + +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) + if err != nil { + return errors.Wrapf(err, "error migrating containers") + } + if err := r.Shutdown(false); err != nil { + return err + } + + return nil +} diff --git a/cmd/podman/system_prune.go b/cmd/podman/system_prune.go index 8900e2644..8a648b603 100644 --- a/cmd/podman/system_prune.go +++ b/cmd/podman/system_prune.go @@ -72,7 +72,7 @@ Are you sure you want to continue? [y/N] `, volumeString) } } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } @@ -110,7 +110,7 @@ Are you sure you want to continue? [y/N] `, volumeString) // Call prune; if any cids are returned, print them and then // return err in case an error also came up - pruneCids, err := runtime.PruneImages(c.All) + pruneCids, err := runtime.PruneImages(ctx, c.All) if len(pruneCids) > 0 { fmt.Println("Deleted Images") for _, cid := range pruneCids { diff --git a/cmd/podman/system_renumber.go b/cmd/podman/system_renumber.go index 70ba706bb..81752a177 100644 --- a/cmd/podman/system_renumber.go +++ b/cmd/podman/system_renumber.go @@ -40,7 +40,7 @@ func renumberCmd(c *cliconfig.SystemRenumberValues) error { // We need to pass one extra option to NewRuntime. // This will inform the OCI runtime to start a renumber. // That's controlled by the last argument to GetRuntime. - r, err := libpodruntime.GetRuntimeRenumber(&c.PodmanCommand) + r, err := libpodruntime.GetRuntimeRenumber(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error renumbering locks") } diff --git a/cmd/podman/tag.go b/cmd/podman/tag.go index deda4e985..58f221e26 100644 --- a/cmd/podman/tag.go +++ b/cmd/podman/tag.go @@ -38,7 +38,7 @@ func tagCmd(c *cliconfig.TagValues) error { if len(args) < 2 { return errors.Errorf("image name and at least one new name must be specified") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } diff --git a/cmd/podman/top.go b/cmd/podman/top.go index 0b7da64a8..2e0a22d92 100644 --- a/cmd/podman/top.go +++ b/cmd/podman/top.go @@ -7,8 +7,8 @@ import ( "text/tabwriter" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/libpod" + "github.com/containers/libpod/pkg/adapter" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -60,7 +60,6 @@ func init() { } func topCmd(c *cliconfig.TopValues) error { - var container *libpod.Container var err error args := c.InputArgs @@ -77,37 +76,16 @@ func topCmd(c *cliconfig.TopValues) error { return errors.Errorf("you must provide the name or id of a running container") } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } defer runtime.Shutdown(false) - var descriptors []string - if c.Latest { - descriptors = args - container, err = runtime.GetLatestContainer() - } else { - descriptors = args[1:] - container, err = runtime.LookupContainer(args[0]) - } - - if err != nil { - return errors.Wrapf(err, "unable to lookup requested container") - } - - conStat, err := container.State() - if err != nil { - return errors.Wrapf(err, "unable to look up state for %s", args[0]) - } - if conStat != libpod.ContainerStateRunning { - return errors.Errorf("top can only be used on running containers") - } - psOutput, err := container.GetContainerPidInformation(descriptors) + psOutput, err := runtime.Top(c) if err != nil { return err } - w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0) for _, proc := range psOutput { fmt.Fprintln(w, proc) diff --git a/cmd/podman/tree.go b/cmd/podman/tree.go index f205c83e4..6490c609d 100644 --- a/cmd/podman/tree.go +++ b/cmd/podman/tree.go @@ -51,7 +51,7 @@ func treeCmd(c *cliconfig.TreeValues) error { return errors.Errorf("you must provide at most 1 argument") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go index 580331673..b615f6266 100644 --- a/cmd/podman/trust_set_show.go +++ b/cmd/podman/trust_set_show.go @@ -74,7 +74,7 @@ File(s) must exist before using this command`) } func showTrustCmd(c *cliconfig.ShowTrustValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } @@ -131,7 +131,7 @@ func showTrustCmd(c *cliconfig.ShowTrustValues) error { } func setTrustCmd(c *cliconfig.SetTrustValues) error { - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } diff --git a/cmd/podman/umount.go b/cmd/podman/umount.go index cdf8b951a..ddbd00bd5 100644 --- a/cmd/podman/umount.go +++ b/cmd/podman/umount.go @@ -48,7 +48,7 @@ func init() { } func umountCmd(c *cliconfig.UmountValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating runtime") } diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go index fa946bfd7..2cd6846fe 100644 --- a/cmd/podman/unpause.go +++ b/cmd/podman/unpause.go @@ -42,7 +42,7 @@ func unpauseCmd(c *cliconfig.UnpauseValues) error { return errors.New("unpause is not supported for rootless containers") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } diff --git a/cmd/podman/varlink.go b/cmd/podman/varlink.go index 787ad01cd..978678a84 100644 --- a/cmd/podman/varlink.go +++ b/cmd/podman/varlink.go @@ -55,7 +55,7 @@ func varlinkCmd(c *cliconfig.VarlinkValues) error { timeout := time.Duration(c.Timeout) * time.Millisecond // Create a single runtime for varlink - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index 1fde72164..309f9765a 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -346,6 +346,7 @@ type Create ( publishAll: ?bool, quiet: ?bool, readonly: ?bool, + readonlytmpfs: ?bool, restart: ?string, rm: ?bool, rootfs: ?bool, @@ -524,6 +525,8 @@ method Ps(opts: PsOpts) -> (containers: []PsContainer) method GetContainersByStatus(status: []string) -> (containerS: []Container) +method Top (nameOrID: string, descriptors: []string) -> (top: []string) + # GetContainer returns information about a single container. If a container # with the given id doesn't exist, a [ContainerNotFound](#ContainerNotFound) # error will be returned. See also [ListContainers](ListContainers) and diff --git a/cmd/podman/volume_create.go b/cmd/podman/volume_create.go index 2b10adb2b..84f6bba94 100644 --- a/cmd/podman/volume_create.go +++ b/cmd/podman/volume_create.go @@ -42,7 +42,7 @@ func init() { } func volumeCreateCmd(c *cliconfig.VolumeCreateValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/volume_inspect.go b/cmd/podman/volume_inspect.go index 66d394307..e4b05f96a 100644 --- a/cmd/podman/volume_inspect.go +++ b/cmd/podman/volume_inspect.go @@ -43,7 +43,7 @@ func volumeInspectCmd(c *cliconfig.VolumeInspectValues) error { return errors.New("provide one or more volume names or use --all") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/volume_ls.go b/cmd/podman/volume_ls.go index b9ab89196..581e595cb 100644 --- a/cmd/podman/volume_ls.go +++ b/cmd/podman/volume_ls.go @@ -72,7 +72,7 @@ func init() { } func volumeLsCmd(c *cliconfig.VolumeLsValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/volume_prune.go b/cmd/podman/volume_prune.go index ad62bfc22..6dc9e2403 100644 --- a/cmd/podman/volume_prune.go +++ b/cmd/podman/volume_prune.go @@ -63,7 +63,7 @@ func volumePrune(runtime *adapter.LocalRuntime, ctx context.Context) error { } func volumePruneCmd(c *cliconfig.VolumePruneValues) error { - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/volume_rm.go b/cmd/podman/volume_rm.go index 4534019c6..77137eb7a 100644 --- a/cmd/podman/volume_rm.go +++ b/cmd/podman/volume_rm.go @@ -47,7 +47,7 @@ func volumeRmCmd(c *cliconfig.VolumeRmValues) error { return errors.New("choose either one or more volumes or all") } - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go index 97ec75b0c..380e861ed 100644 --- a/cmd/podman/wait.go +++ b/cmd/podman/wait.go @@ -51,7 +51,7 @@ func waitCmd(c *cliconfig.WaitValues) error { } interval := time.Duration(c.Interval) * time.Millisecond - runtime, err := adapter.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating runtime") } |