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
622b9f45
Commit
622b9f45
authored
Sep 05, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/docker: lock around Login
parent
e9611dfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
builder/docker/driver.go
builder/docker/driver.go
+3
-2
builder/docker/driver_docker.go
builder/docker/driver_docker.go
+16
-3
No files found.
builder/docker/driver.go
View file @
622b9f45
...
@@ -20,10 +20,11 @@ type Driver interface {
...
@@ -20,10 +20,11 @@ type Driver interface {
// Import imports a container from a tar file
// Import imports a container from a tar file
Import
(
path
,
repo
string
)
(
string
,
error
)
Import
(
path
,
repo
string
)
(
string
,
error
)
// Login
// Login. This will lock the driver from performing another Login
// until Logout is called. Therefore, any users MUST call Logout.
Login
(
repo
,
email
,
username
,
password
string
)
error
Login
(
repo
,
email
,
username
,
password
string
)
error
// Logout
// Logout
. This can only be called if Login succeeded.
Logout
(
repo
string
)
error
Logout
(
repo
string
)
error
// Pull should pull down the given image.
// Pull should pull down the given image.
...
...
builder/docker/driver_docker.go
View file @
622b9f45
...
@@ -3,17 +3,21 @@ package docker
...
@@ -3,17 +3,21 @@ package docker
import
(
import
(
"bytes"
"bytes"
"fmt"
"fmt"
"github.com/mitchellh/packer/packer"
"io"
"io"
"log"
"log"
"os"
"os"
"os/exec"
"os/exec"
"strings"
"strings"
"sync"
"github.com/mitchellh/packer/packer"
)
)
type
DockerDriver
struct
{
type
DockerDriver
struct
{
Ui
packer
.
Ui
Ui
packer
.
Ui
Tpl
*
packer
.
ConfigTemplate
Tpl
*
packer
.
ConfigTemplate
l
sync
.
Mutex
}
}
func
(
d
*
DockerDriver
)
DeleteImage
(
id
string
)
error
{
func
(
d
*
DockerDriver
)
DeleteImage
(
id
string
)
error
{
...
@@ -110,6 +114,8 @@ func (d *DockerDriver) Import(path string, repo string) (string, error) {
...
@@ -110,6 +114,8 @@ func (d *DockerDriver) Import(path string, repo string) (string, error) {
}
}
func
(
d
*
DockerDriver
)
Login
(
repo
,
email
,
user
,
pass
string
)
error
{
func
(
d
*
DockerDriver
)
Login
(
repo
,
email
,
user
,
pass
string
)
error
{
d
.
l
.
Lock
()
args
:=
[]
string
{
"login"
}
args
:=
[]
string
{
"login"
}
if
email
!=
""
{
if
email
!=
""
{
args
=
append
(
args
,
"-e"
,
email
)
args
=
append
(
args
,
"-e"
,
email
)
...
@@ -125,7 +131,12 @@ func (d *DockerDriver) Login(repo, email, user, pass string) error {
...
@@ -125,7 +131,12 @@ func (d *DockerDriver) Login(repo, email, user, pass string) error {
}
}
cmd
:=
exec
.
Command
(
"docker"
,
args
...
)
cmd
:=
exec
.
Command
(
"docker"
,
args
...
)
return
runAndStream
(
cmd
,
d
.
Ui
)
err
:=
runAndStream
(
cmd
,
d
.
Ui
)
if
err
!=
nil
{
d
.
l
.
Unlock
()
}
return
err
}
}
func
(
d
*
DockerDriver
)
Logout
(
repo
string
)
error
{
func
(
d
*
DockerDriver
)
Logout
(
repo
string
)
error
{
...
@@ -135,7 +146,9 @@ func (d *DockerDriver) Logout(repo string) error {
...
@@ -135,7 +146,9 @@ func (d *DockerDriver) Logout(repo string) error {
}
}
cmd
:=
exec
.
Command
(
"docker"
,
args
...
)
cmd
:=
exec
.
Command
(
"docker"
,
args
...
)
return
runAndStream
(
cmd
,
d
.
Ui
)
err
:=
runAndStream
(
cmd
,
d
.
Ui
)
d
.
l
.
Unlock
()
return
err
}
}
func
(
d
*
DockerDriver
)
Pull
(
image
string
)
error
{
func
(
d
*
DockerDriver
)
Pull
(
image
string
)
error
{
...
...
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