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
a6150e65
Commit
a6150e65
authored
Nov 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/all: update to warnings
parent
3cd7379d
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
544 additions
and
151 deletions
+544
-151
builder/digitalocean/builder.go
builder/digitalocean/builder.go
+5
-5
builder/digitalocean/builder_test.go
builder/digitalocean/builder_test.go
+100
-25
builder/openstack/builder.go
builder/openstack/builder.go
+5
-5
builder/openstack/builder_test.go
builder/openstack/builder_test.go
+20
-5
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+5
-5
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+224
-56
builder/vmware/builder.go
builder/vmware/builder.go
+5
-5
builder/vmware/builder_test.go
builder/vmware/builder_test.go
+180
-45
No files found.
builder/digitalocean/builder.go
View file @
a6150e65
...
...
@@ -49,15 +49,15 @@ type Builder struct {
runner
multistep
.
Runner
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
...
...
@@ -161,11 +161,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b
.
config
.
stateTimeout
=
stateTimeout
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
ClientID
,
b
.
config
.
APIKey
)
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/digitalocean/builder_test.go
View file @
a6150e65
...
...
@@ -34,7 +34,10 @@ func TestBuilder_Prepare_BadType(t *testing.T) {
"api_key"
:
[]
string
{},
}
err
:=
b
.
Prepare
(
c
)
warnings
,
err
:=
b
.
Prepare
(
c
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatalf
(
"prepare should fail"
)
}
...
...
@@ -46,7 +49,10 @@ func TestBuilderPrepare_APIKey(t *testing.T) {
// Test good
config
[
"api_key"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -58,7 +64,10 @@ func TestBuilderPrepare_APIKey(t *testing.T) {
// Test bad
delete
(
config
,
"api_key"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -67,7 +76,10 @@ func TestBuilderPrepare_APIKey(t *testing.T) {
delete
(
config
,
"api_key"
)
os
.
Setenv
(
"DIGITALOCEAN_API_KEY"
,
"foo"
)
defer
os
.
Setenv
(
"DIGITALOCEAN_API_KEY"
,
""
)
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -79,7 +91,10 @@ func TestBuilderPrepare_ClientID(t *testing.T) {
// Test good
config
[
"client_id"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -91,7 +106,10 @@ func TestBuilderPrepare_ClientID(t *testing.T) {
// Test bad
delete
(
config
,
"client_id"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -100,7 +118,10 @@ func TestBuilderPrepare_ClientID(t *testing.T) {
delete
(
config
,
"client_id"
)
os
.
Setenv
(
"DIGITALOCEAN_CLIENT_ID"
,
"foo"
)
defer
os
.
Setenv
(
"DIGITALOCEAN_CLIENT_ID"
,
""
)
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -112,7 +133,10 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
// Add a random key
config
[
"i_should_not_be_valid"
]
=
true
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -123,7 +147,10 @@ func TestBuilderPrepare_RegionID(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -135,7 +162,10 @@ func TestBuilderPrepare_RegionID(t *testing.T) {
// Test set
config
[
"region_id"
]
=
2
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -150,7 +180,10 @@ func TestBuilderPrepare_SizeID(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -162,7 +195,10 @@ func TestBuilderPrepare_SizeID(t *testing.T) {
// Test set
config
[
"size_id"
]
=
67
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -177,7 +213,10 @@ func TestBuilderPrepare_ImageID(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -189,7 +228,10 @@ func TestBuilderPrepare_ImageID(t *testing.T) {
// Test set
config
[
"size_id"
]
=
2
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -204,7 +246,10 @@ func TestBuilderPrepare_SSHUsername(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -216,7 +261,10 @@ func TestBuilderPrepare_SSHUsername(t *testing.T) {
// Test set
config
[
"ssh_username"
]
=
"foo"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -231,7 +279,10 @@ func TestBuilderPrepare_SSHTimeout(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -243,7 +294,10 @@ func TestBuilderPrepare_SSHTimeout(t *testing.T) {
// Test set
config
[
"ssh_timeout"
]
=
"30s"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -251,7 +305,10 @@ func TestBuilderPrepare_SSHTimeout(t *testing.T) {
// Test bad
config
[
"ssh_timeout"
]
=
"tubes"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -263,7 +320,10 @@ func TestBuilderPrepare_StateTimeout(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -275,7 +335,10 @@ func TestBuilderPrepare_StateTimeout(t *testing.T) {
// Test set
config
[
"state_timeout"
]
=
"5m"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -283,7 +346,10 @@ func TestBuilderPrepare_StateTimeout(t *testing.T) {
// Test bad
config
[
"state_timeout"
]
=
"tubes"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -295,7 +361,10 @@ func TestBuilderPrepare_SnapshotName(t *testing.T) {
config
:=
testConfig
()
// Test default
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -307,7 +376,10 @@ func TestBuilderPrepare_SnapshotName(t *testing.T) {
// Test set
config
[
"snapshot_name"
]
=
"foobarbaz"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -315,7 +387,10 @@ func TestBuilderPrepare_SnapshotName(t *testing.T) {
// Test set with template
config
[
"snapshot_name"
]
=
"{{timestamp}}"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
builder/openstack/builder.go
View file @
a6150e65
...
...
@@ -29,15 +29,15 @@ type Builder struct {
runner
multistep
.
Runner
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
...
...
@@ -48,11 +48,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
log
.
Println
(
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
Password
))
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/openstack/builder_test.go
View file @
a6150e65
...
...
@@ -32,7 +32,10 @@ func TestBuilder_Prepare_BadType(t *testing.T) {
"password"
:
[]
string
{},
}
err
:=
b
.
Prepare
(
c
)
warns
,
err
:=
b
.
Prepare
(
c
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatalf
(
"prepare should fail"
)
}
...
...
@@ -44,7 +47,10 @@ func TestBuilderPrepare_ImageName(t *testing.T) {
// Test good
config
[
"image_name"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -52,7 +58,10 @@ func TestBuilderPrepare_ImageName(t *testing.T) {
// Test bad
config
[
"image_name"
]
=
"foo {{"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -60,7 +69,10 @@ func TestBuilderPrepare_ImageName(t *testing.T) {
// Test bad
delete
(
config
,
"image_name"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -72,7 +84,10 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
// Add a random key
config
[
"i_should_not_be_valid"
]
=
true
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
builder/virtualbox/builder.go
View file @
a6150e65
...
...
@@ -72,15 +72,15 @@ type config struct {
tpl
*
packer
.
ConfigTemplate
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
...
...
@@ -364,10 +364,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/virtualbox/builder_test.go
View file @
a6150e65
This diff is collapsed.
Click to expand it.
builder/vmware/builder.go
View file @
a6150e65
...
...
@@ -66,15 +66,15 @@ type config struct {
tpl
*
packer
.
ConfigTemplate
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
...
...
@@ -327,10 +327,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/vmware/builder_test.go
View file @
a6150e65
This diff is collapsed.
Click to expand 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