diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-05-28 13:27:23 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-06-11 11:01:13 +0200 |
commit | 7d71d24440afbf30689c53c2c69205072e4b029f (patch) | |
tree | 20ae3d75ac79b2e9cf5a237ce4582ecd6a508b9c /cmd/podman/pods/start.go | |
parent | 7f5aabb08389f9baee49bd76ab21f876e0bb70b9 (diff) | |
download | podman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.gz podman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.bz2 podman-7d71d24440afbf30689c53c2c69205072e4b029f.zip |
podman-pod{rm,start,stop}: support --pod-id-file
Support the `--pod-id-file` flag in the rm, start and stop pod commands.
This completes the already support flag in pod-create and is another
prerequisite for generating generic systemd unit files for pods.
Also add completions, docs and tests.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/pods/start.go')
-rw-r--r-- | cmd/podman/pods/start.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/podman/pods/start.go b/cmd/podman/pods/start.go index d0150a3c2..86517190d 100644 --- a/cmd/podman/pods/start.go +++ b/cmd/podman/pods/start.go @@ -11,6 +11,13 @@ import ( "github.com/spf13/cobra" ) +// allows for splitting API and CLI-only options +type podStartOptionsWrapper struct { + entities.PodStartOptions + + PodIDFiles []string +} + var ( podStartDescription = `The pod name or ID can be used. @@ -21,7 +28,7 @@ var ( Long: podStartDescription, RunE: start, Args: func(cmd *cobra.Command, args []string) error { - return parse.CheckAllLatestAndCIDFile(cmd, args, false, false) + return parse.CheckAllLatestAndPodIDFile(cmd, args, false, true) }, Example: `podman pod start podID podman pod start --latest @@ -30,7 +37,7 @@ var ( ) var ( - startOptions = entities.PodStartOptions{} + startOptions = podStartOptionsWrapper{} ) func init() { @@ -43,6 +50,7 @@ func init() { flags := startCommand.Flags() flags.BoolVarP(&startOptions.All, "all", "a", false, "Restart all running pods") flags.BoolVarP(&startOptions.Latest, "latest", "l", false, "Restart the latest pod podman is aware of") + flags.StringArrayVarP(&startOptions.PodIDFiles, "pod-id-file", "", nil, "Read the pod ID from the file") if registry.IsRemote() { _ = flags.MarkHidden("latest") } @@ -52,7 +60,14 @@ func start(cmd *cobra.Command, args []string) error { var ( errs utils.OutputErrors ) - responses, err := registry.ContainerEngine().PodStart(context.Background(), args, startOptions) + + ids, err := readPodIDFiles(startOptions.PodIDFiles) + if err != nil { + return err + } + args = append(args, ids...) + + responses, err := registry.ContainerEngine().PodStart(context.Background(), args, startOptions.PodStartOptions) if err != nil { return err } |