Skip to content

Commit

Permalink
hotfix exec command
Browse files Browse the repository at this point in the history
  • Loading branch information
mcuadros committed Sep 30, 2015
1 parent f086da6 commit e719513
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions core/execjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package core
import (
"errors"
"fmt"
"strings"

"github.com/fsouza/go-dockerclient"
)

const BashBin = "/bin/bash"

var ErrUnexpected = errors.New("error unexpected, docker has returned exit code -1, maybe wrong user?")

type ExecJob struct {
Expand Down Expand Up @@ -50,7 +49,7 @@ func (j *ExecJob) buildExec() (*docker.Exec, error) {
AttachStdout: true,
AttachStderr: true,
Tty: j.TTY,
Cmd: []string{BashBin, "-c", `"` + j.Command + `"`},
Cmd: strings.Split(j.Command, " "),
Container: j.Container,
User: j.User,
})
Expand Down
6 changes: 3 additions & 3 deletions core/execjob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *SuiteExecJob) TestRun(c *C) {

job := &ExecJob{Client: s.client}
job.Container = ContainerFixture
job.Command = "ls"
job.Command = "ls -a"
job.User = "foo"
job.TTY = true
job.Run()
Expand All @@ -53,8 +53,8 @@ func (s *SuiteExecJob) TestRun(c *C) {

exec, err := s.client.InspectExec(container.ExecIDs[0])
c.Assert(err, IsNil)
c.Assert(exec.ProcessConfig.EntryPoint, Equals, "/bin/bash")
c.Assert(exec.ProcessConfig.Arguments, DeepEquals, []string{"-c", `"ls"`})
c.Assert(exec.ProcessConfig.EntryPoint, Equals, "ls")
c.Assert(exec.ProcessConfig.Arguments, DeepEquals, []string{"-a"})
c.Assert(exec.ProcessConfig.User, Equals, "foo")
c.Assert(exec.ProcessConfig.Tty, Equals, true)
}
Expand Down

0 comments on commit e719513

Please sign in to comment.