Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/podman/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/podman/cliconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ type SystemRenumberValues struct {
PodmanCommand
}

type SystemMigrateValues struct {
PodmanCommand
}

type SystemDfValues struct {
PodmanCommand
Verbose bool
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func getSystemSubCommands() []*cobra.Command {
_pruneSystemCommand,
_renumberCommand,
_dfSystemCommand,
_migrateCommand,
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/containers_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/podman/exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/generate_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/healthcheck_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/images_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
22 changes: 17 additions & 5 deletions cmd/podman/libpodruntime/runtime.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/main_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/play_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pod_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pod_kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pod_pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/pod_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Loading