summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-30 15:27:37 +0200
committerGitHub <noreply@github.com>2020-04-30 15:27:37 +0200
commitfc9451ed15e3ea2fbdcd5754b367db74eec1063e (patch)
tree7809c97d047c313d6f78a5f05b075710d2f2aa50 /cmd
parent99f8cfc2dc39b11cd315062167f1ffaf85eda946 (diff)
parent75eeb40f41f2839dc91281e24b1094180b97a8aa (diff)
downloadpodman-fc9451ed15e3ea2fbdcd5754b367db74eec1063e.tar.gz
podman-fc9451ed15e3ea2fbdcd5754b367db74eec1063e.tar.bz2
podman-fc9451ed15e3ea2fbdcd5754b367db74eec1063e.zip
Merge pull request #6047 from QiWang19/attach-test
testv2: enable attach test
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/attach.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go
index 78b52ad1b..ee4d811d7 100644
--- a/cmd/podman/containers/attach.go
+++ b/cmd/podman/containers/attach.go
@@ -71,11 +71,18 @@ func init() {
}
func attach(cmd *cobra.Command, args []string) error {
+ if len(args) > 1 || (len(args) == 0 && !attachOpts.Latest) {
+ return errors.Errorf("attach requires the name or id of one running container or the latest flag")
+ }
+ var name string
+ if len(args) > 0 {
+ name = args[0]
+ }
attachOpts.Stdin = os.Stdin
if attachOpts.NoStdin {
attachOpts.Stdin = nil
}
attachOpts.Stdout = os.Stdout
attachOpts.Stderr = os.Stderr
- return registry.ContainerEngine().ContainerAttach(registry.GetContext(), args[0], attachOpts)
+ return registry.ContainerEngine().ContainerAttach(registry.GetContext(), name, attachOpts)
}