mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00
add detach keys support for remote
Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
2
API.md
2
API.md
@ -1591,6 +1591,8 @@ user [?string](#?string)
|
|||||||
workdir [?string](#?string)
|
workdir [?string](#?string)
|
||||||
|
|
||||||
env [?[]string](#?[]string)
|
env [?[]string](#?[]string)
|
||||||
|
|
||||||
|
detachKeys [?string](#?string)
|
||||||
### <a name="Image"></a>type Image
|
### <a name="Image"></a>type Image
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,7 +514,9 @@ type ExecOpts(
|
|||||||
# workdir to run command in container
|
# workdir to run command in container
|
||||||
workdir: ?string,
|
workdir: ?string,
|
||||||
# slice of keyword=value environment variables
|
# slice of keyword=value environment variables
|
||||||
env: ?[]string
|
env: ?[]string,
|
||||||
|
# string of detach keys
|
||||||
|
detachKeys: ?string
|
||||||
)
|
)
|
||||||
|
|
||||||
# GetVersion returns version and build information of the podman service
|
# GetVersion returns version and build information of the podman service
|
||||||
|
@ -1017,7 +1017,6 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
|
|||||||
|
|
||||||
// Check if we are attached to a terminal. If we are, generate resize
|
// Check if we are attached to a terminal. If we are, generate resize
|
||||||
// events, and set the terminal to raw mode
|
// events, and set the terminal to raw mode
|
||||||
// TODO FIXME tty
|
|
||||||
if haveTerminal && cli.Tty {
|
if haveTerminal && cli.Tty {
|
||||||
cancel, oldTermState, err := handleTerminalAttach(ctx, resize)
|
cancel, oldTermState, err := handleTerminalAttach(ctx, resize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1038,6 +1037,7 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
|
|||||||
User: &cli.User,
|
User: &cli.User,
|
||||||
Workdir: &cli.Workdir,
|
Workdir: &cli.Workdir,
|
||||||
Env: &envs,
|
Env: &envs,
|
||||||
|
DetachKeys: &cli.DetachKeys,
|
||||||
}
|
}
|
||||||
|
|
||||||
inputStream := os.Stdin
|
inputStream := os.Stdin
|
||||||
|
@ -782,6 +782,9 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO
|
|||||||
fmt.Sprintf("exec requires a running container, %s is %s", ctr.ID(), state.String()))
|
fmt.Sprintf("exec requires a running container, %s is %s", ctr.ID(), state.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ACK the client upgrade request
|
||||||
|
call.ReplyExecContainer()
|
||||||
|
|
||||||
envs := []string{}
|
envs := []string{}
|
||||||
if opts.Env != nil {
|
if opts.Env != nil {
|
||||||
envs = *opts.Env
|
envs = *opts.Env
|
||||||
@ -796,8 +799,11 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO
|
|||||||
if opts.Workdir != nil {
|
if opts.Workdir != nil {
|
||||||
workDir = *opts.Workdir
|
workDir = *opts.Workdir
|
||||||
}
|
}
|
||||||
// ACK the client upgrade request
|
|
||||||
call.ReplyExecContainer()
|
var detachKeys string
|
||||||
|
if opts.DetachKeys != nil {
|
||||||
|
detachKeys = *opts.DetachKeys
|
||||||
|
}
|
||||||
|
|
||||||
resizeChan := make(chan remotecommand.TerminalSize)
|
resizeChan := make(chan remotecommand.TerminalSize)
|
||||||
|
|
||||||
@ -818,11 +824,10 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// TODO FIXME detach keys
|
|
||||||
go func() {
|
go func() {
|
||||||
ec, err := ctr.Exec(opts.Tty, opts.Privileged, envs, opts.Cmd, user, workDir, streams, 0, resizeChan, "")
|
ec, err := ctr.Exec(opts.Tty, opts.Privileged, envs, opts.Cmd, user, workDir, streams, 0, resizeChan, detachKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("ExecContainer Exec err %s, %s\n", err.Error(), errors.Cause(err).Error())
|
logrus.Errorf(err.Error())
|
||||||
}
|
}
|
||||||
ecErrChan <- ExitCodeError{
|
ecErrChan <- ExitCodeError{
|
||||||
uint32(ec),
|
uint32(ec),
|
||||||
|
@ -77,8 +77,6 @@ var _ = Describe("Podman exec", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec environment test", func() {
|
It("podman exec environment test", func() {
|
||||||
// passing environment variables is not supported in the remote client
|
|
||||||
SkipIfRemote()
|
|
||||||
setup := podmanTest.RunTopContainer("test1")
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
Expect(setup.ExitCode()).To(Equal(0))
|
Expect(setup.ExitCode()).To(Equal(0))
|
||||||
@ -110,8 +108,8 @@ var _ = Describe("Podman exec", func() {
|
|||||||
match, _ := session.GrepString("BAR")
|
match, _ := session.GrepString("BAR")
|
||||||
Expect(match).Should(BeTrue())
|
Expect(match).Should(BeTrue())
|
||||||
os.Unsetenv("FOO")
|
os.Unsetenv("FOO")
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman exec exit code", func() {
|
It("podman exec exit code", func() {
|
||||||
setup := podmanTest.RunTopContainer("test1")
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user