Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
31ac2652
Commit
31ac2652
authored
May 29, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bulder/docker: canExec as sep function
parent
ce275969
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
builder/docker/communicator.go
builder/docker/communicator.go
+10
-9
No files found.
builder/docker/communicator.go
View file @
31ac2652
...
...
@@ -29,14 +29,6 @@ type Communicator struct {
}
func
(
c
*
Communicator
)
Start
(
remote
*
packer
.
RemoteCmd
)
error
{
// Determine if we're using docker exec or not
useExec
:=
false
execConstraint
,
err
:=
version
.
NewConstraint
(
">= 1.4.0"
)
if
err
!=
nil
{
return
err
}
useExec
=
execConstraint
.
Check
(
c
.
Version
)
// Create a temporary file to store the output. Because of a bug in
// Docker, sometimes all the output doesn't properly show up. This
// file will capture ALL of the output, and we'll read that.
...
...
@@ -52,7 +44,7 @@ func (c *Communicator) Start(remote *packer.RemoteCmd) error {
exitCodePath
:=
outputFile
.
Name
()
+
"-exit"
var
cmd
*
exec
.
Cmd
if
useExec
{
if
c
.
canExec
()
{
cmd
=
exec
.
Command
(
"docker"
,
"exec"
,
"-i"
,
c
.
ContainerId
,
"/bin/sh"
)
}
else
{
cmd
=
exec
.
Command
(
"docker"
,
"attach"
,
c
.
ContainerId
)
...
...
@@ -202,6 +194,15 @@ func (c *Communicator) Download(src string, dst io.Writer) error {
panic
(
"not implemented"
)
}
// canExec tells us whether `docker exec` is supported
func
(
c
*
Communicator
)
canExec
()
bool
{
execConstraint
,
err
:=
version
.
NewConstraint
(
">= 1.4.0"
)
if
err
!=
nil
{
panic
(
err
)
}
return
execConstraint
.
Check
(
c
.
Version
)
}
// Runs the given command and blocks until completion
func
(
c
*
Communicator
)
run
(
cmd
*
exec
.
Cmd
,
remote
*
packer
.
RemoteCmd
,
stdin_w
io
.
WriteCloser
,
outputFile
*
os
.
File
,
exitCodePath
string
)
{
// For Docker, remote communication must be serialized since it
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment