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
a0e533db
Commit
a0e533db
authored
Jan 01, 2014
by
Matthew McKeen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename docker post processor to docker-push.
Implement login to a docker registry, error handling
parent
ae8bffcd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
+29
-10
config.go
config.go
+1
-1
plugin/post-processor-docker-push/main.go
plugin/post-processor-docker-push/main.go
+2
-2
plugin/post-processor-docker-push/main_test.go
plugin/post-processor-docker-push/main_test.go
+0
-0
post-processor/docker-push/post-processor.go
post-processor/docker-push/post-processor.go
+26
-7
No files found.
config.go
View file @
a0e533db
...
...
@@ -43,7 +43,7 @@ const defaultConfig = `
"post-processors": {
"vagrant": "packer-post-processor-vagrant",
"vsphere": "packer-post-processor-vsphere",
"docker
": "packer-post-processor-docker
"
"docker
-push": "packer-post-processor-docker-push
"
},
"provisioners": {
...
...
plugin/post-processor-docker/main.go
→
plugin/post-processor-docker
-push
/main.go
View file @
a0e533db
...
...
@@ -2,7 +2,7 @@ package main
import
(
"github.com/mitchellh/packer/packer/plugin"
"github.com/mitchellh/packer/post-processor/docker"
"github.com/mitchellh/packer/post-processor/docker
-push
"
)
func
main
()
{
...
...
@@ -10,6 +10,6 @@ func main() {
if
err
!=
nil
{
panic
(
err
)
}
server
.
RegisterPostProcessor
(
new
(
docker
.
PostProcessor
))
server
.
RegisterPostProcessor
(
new
(
docker
push
.
PostProcessor
))
server
.
Serve
()
}
plugin/post-processor-docker/main_test.go
→
plugin/post-processor-docker
-push
/main_test.go
View file @
a0e533db
File moved
post-processor/docker/post-processor.go
→
post-processor/docker
-push
/post-processor.go
View file @
a0e533db
package
docker
package
docker
push
import
(
"bytes"
"errors"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
...
...
@@ -38,18 +37,38 @@ func (p *PostProcessor) Configure(raw ...interface{}) error {
return
nil
}
func
(
p
*
PostProcessor
)
PostProcess
(
ui
packer
.
Ui
,
artifact
packer
.
Artifact
)
(
packer
.
Artifact
,
bool
,
error
)
{
id
:=
artifact
.
Id
()
ui
.
Say
(
"Pushing imgage: "
+
id
)
ui
.
Say
(
"Pushing image: "
+
id
)
if
p
.
config
.
Email
==
""
{
cmd
:=
exec
.
Command
(
"docker"
,
"login"
,
"-u=
\"
"
+
p
.
config
.
Username
+
"
\"
"
,
"-p=
\"
"
+
p
.
config
.
Password
+
"
\"
"
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Say
(
"Login to the registry "
+
p
.
config
.
Registry
+
" failed"
)
return
nil
,
false
,
err
}
// TODO: docker login
}
else
{
cmd
:=
exec
.
Command
(
"docker"
,
"login"
,
"-u=
\"
"
+
p
.
config
.
Username
+
"
\"
"
,
"-p=
\"
"
+
p
.
config
.
Password
+
"
\"
"
,
"-e=
\"
"
+
p
.
config
.
Email
+
"
\"
"
)
stdout
:=
new
(
bytes
.
Buffer
)
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Say
(
"Login to the registry "
+
p
.
config
.
Registry
+
" failed"
)
return
nil
,
false
,
err
}
}
cmd
:=
exec
.
Command
(
"docker"
,
"push"
,
id
)
cmd
.
Stdout
=
stdout
if
err
:=
cmd
.
Run
();
err
!=
nil
{
ui
.
Say
(
"Failed to push image: "
+
id
)
return
nil
,
tru
e
,
err
return
nil
,
fals
e
,
err
}
return
nil
,
true
,
nil
...
...
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