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
6fe0cb76
Commit
6fe0cb76
authored
Mar 12, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/docker-push: allow repo with ports [GH-923]
parent
46abd505
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
4 deletions
+98
-4
CHANGELOG.md
CHANGELOG.md
+1
-0
post-processor/docker-push/post-processor.go
post-processor/docker-push/post-processor.go
+14
-4
post-processor/docker-push/post-processor_test.go
post-processor/docker-push/post-processor_test.go
+83
-0
No files found.
CHANGELOG.md
View file @
6fe0cb76
...
...
@@ -18,6 +18,7 @@ BUG FIXES:
*
builder/virtualbox-iso: Retry unregister a few times to deal with
VBoxManage randomness. [GH-915]
*
provisioners/chef-client: Don't chown directory with Ubuntu. [GH-939]
*
post-processor/docker-push: Allow repositories with ports. [GH-923]
## 0.5.2 (02/21/2014)
...
...
post-processor/docker-push/post-processor.go
View file @
6fe0cb76
...
...
@@ -16,6 +16,8 @@ type Config struct {
}
type
PostProcessor
struct
{
Driver
docker
.
Driver
config
Config
}
...
...
@@ -38,7 +40,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
return
nil
}
func
(
p
*
PostProcessor
)
PostProcess
(
ui
packer
.
Ui
,
artifact
packer
.
Artifact
)
(
packer
.
Artifact
,
bool
,
error
)
{
...
...
@@ -49,13 +50,22 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return
nil
,
false
,
err
}
driver
:=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
driver
:=
p
.
Driver
if
driver
==
nil
{
// If no driver is set, then we use the real driver
driver
=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
}
// Get the name. We strip off any tags from the name because the
// push doesn't use those.
name
:=
artifact
.
Id
()
if
i
:=
strings
.
Index
(
name
,
":"
);
i
>=
0
{
name
=
name
[
:
i
]
if
i
:=
strings
.
Index
(
name
,
"/"
);
i
>=
0
{
// This should always be true because the / is required. But we have
// to get the index to this so we don't accidentally strip off the port
if
j
:=
strings
.
Index
(
name
[
i
:
],
":"
);
j
>=
0
{
name
=
name
[
:
i
+
j
]
}
}
ui
.
Message
(
"Pushing: "
+
name
)
...
...
post-processor/docker-push/post-processor_test.go
View file @
6fe0cb76
...
...
@@ -2,7 +2,9 @@ package dockerpush
import
(
"bytes"
"github.com/mitchellh/packer/builder/docker"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/post-processor/docker-import"
"testing"
)
...
...
@@ -29,3 +31,84 @@ func testUi() *packer.BasicUi {
func
TestPostProcessor_ImplementsPostProcessor
(
t
*
testing
.
T
)
{
var
_
packer
.
PostProcessor
=
new
(
PostProcessor
)
}
func
TestPostProcessor_PostProcess
(
t
*
testing
.
T
)
{
driver
:=
&
docker
.
MockDriver
{}
p
:=
&
PostProcessor
{
Driver
:
driver
}
artifact
:=
&
packer
.
MockArtifact
{
BuilderIdValue
:
dockerimport
.
BuilderId
,
IdValue
:
"foo/bar"
,
}
result
,
keep
,
err
:=
p
.
PostProcess
(
testUi
(),
artifact
)
if
result
!=
nil
{
t
.
Fatal
(
"should be nil"
)
}
if
keep
{
t
.
Fatal
(
"should not keep"
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
!
driver
.
PushCalled
{
t
.
Fatal
(
"should call push"
)
}
if
driver
.
PushName
!=
"foo/bar"
{
t
.
Fatal
(
"bad name"
)
}
}
func
TestPostProcessor_PostProcess_portInName
(
t
*
testing
.
T
)
{
driver
:=
&
docker
.
MockDriver
{}
p
:=
&
PostProcessor
{
Driver
:
driver
}
artifact
:=
&
packer
.
MockArtifact
{
BuilderIdValue
:
dockerimport
.
BuilderId
,
IdValue
:
"localhost:5000/foo/bar"
,
}
result
,
keep
,
err
:=
p
.
PostProcess
(
testUi
(),
artifact
)
if
result
!=
nil
{
t
.
Fatal
(
"should be nil"
)
}
if
keep
{
t
.
Fatal
(
"should not keep"
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
!
driver
.
PushCalled
{
t
.
Fatal
(
"should call push"
)
}
if
driver
.
PushName
!=
"localhost:5000/foo/bar"
{
t
.
Fatal
(
"bad name"
)
}
}
func
TestPostProcessor_PostProcess_tags
(
t
*
testing
.
T
)
{
driver
:=
&
docker
.
MockDriver
{}
p
:=
&
PostProcessor
{
Driver
:
driver
}
artifact
:=
&
packer
.
MockArtifact
{
BuilderIdValue
:
dockerimport
.
BuilderId
,
IdValue
:
"hashicorp/ubuntu:precise"
,
}
result
,
keep
,
err
:=
p
.
PostProcess
(
testUi
(),
artifact
)
if
result
!=
nil
{
t
.
Fatal
(
"should be nil"
)
}
if
keep
{
t
.
Fatal
(
"should not keep"
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
!
driver
.
PushCalled
{
t
.
Fatal
(
"should call push"
)
}
if
driver
.
PushName
!=
"hashicorp/ubuntu"
{
t
.
Fatalf
(
"bad name: %s"
,
driver
.
PushName
)
}
}
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