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
Show 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
...
...
@@ -60,7 +60,10 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
func
TestBuilderPrepare_Defaults
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
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
)
}
...
...
@@ -104,7 +107,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test a default boot_wait
delete
(
config
,
"boot_wait"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -115,7 +121,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test with a bad boot_wait
config
[
"boot_wait"
]
=
"this is not good"
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"
)
}
...
...
@@ -123,7 +132,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test with a good one
config
[
"boot_wait"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -134,7 +146,10 @@ func TestBuilderPrepare_DiskSize(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"disk_size"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -145,7 +160,10 @@ func TestBuilderPrepare_DiskSize(t *testing.T) {
config
[
"disk_size"
]
=
60000
b
=
Builder
{}
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
)
}
...
...
@@ -160,7 +178,10 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"floppy_files"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -171,7 +192,10 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
config
[
"floppy_files"
]
=
[]
string
{
"foo"
,
"bar"
}
b
=
Builder
{}
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
)
}
...
...
@@ -188,7 +212,10 @@ func TestBuilderPrepare_GuestAdditionsMode(t *testing.T) {
// test default mode
delete
(
config
,
"guest_additions_mode"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -196,7 +223,10 @@ func TestBuilderPrepare_GuestAdditionsMode(t *testing.T) {
// Test another mode
config
[
"guest_additions_mode"
]
=
"attach"
b
=
Builder
{}
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
)
}
...
...
@@ -208,7 +238,10 @@ func TestBuilderPrepare_GuestAdditionsMode(t *testing.T) {
// Test bad mode
config
[
"guest_additions_mode"
]
=
"teleport"
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 error"
)
}
...
...
@@ -219,7 +252,10 @@ func TestBuilderPrepare_GuestAdditionsPath(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"guest_additions_path"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -230,7 +266,10 @@ func TestBuilderPrepare_GuestAdditionsPath(t *testing.T) {
config
[
"guest_additions_path"
]
=
"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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -245,7 +284,10 @@ func TestBuilderPrepare_GuestAdditionsSHA256(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"guest_additions_sha256"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -256,7 +298,10 @@ func TestBuilderPrepare_GuestAdditionsSHA256(t *testing.T) {
config
[
"guest_additions_sha256"
]
=
"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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -271,7 +316,10 @@ func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
config
:=
testConfig
()
config
[
"guest_additions_url"
]
=
""
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -282,7 +330,10 @@ func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
config
[
"guest_additions_url"
]
=
"http://www.packer.io"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -294,7 +345,10 @@ func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
// Test a default boot_wait
delete
(
config
,
"hard_drive_interface"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -306,7 +360,10 @@ func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
// Test with a bad
config
[
"hard_drive_interface"
]
=
"fake"
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"
)
}
...
...
@@ -314,7 +371,10 @@ func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
// Test with a good
config
[
"hard_drive_interface"
]
=
"sata"
b
=
Builder
{}
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
)
}
...
...
@@ -327,7 +387,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
// Bad
config
[
"http_port_min"
]
=
1000
config
[
"http_port_max"
]
=
500
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"
)
}
...
...
@@ -335,7 +398,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
// Bad
config
[
"http_port_min"
]
=
-
500
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"
)
}
...
...
@@ -344,7 +410,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
config
[
"http_port_min"
]
=
500
config
[
"http_port_max"
]
=
1000
b
=
Builder
{}
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
)
}
...
...
@@ -356,7 +425,10 @@ func TestBuilderPrepare_Format(t *testing.T) {
// Bad
config
[
"format"
]
=
"illegal value"
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"
)
}
...
...
@@ -364,7 +436,10 @@ func TestBuilderPrepare_Format(t *testing.T) {
// Good
config
[
"format"
]
=
"ova"
b
=
Builder
{}
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
)
}
...
...
@@ -372,7 +447,10 @@ func TestBuilderPrepare_Format(t *testing.T) {
// Good
config
[
"format"
]
=
"ovf"
b
=
Builder
{}
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
)
}
...
...
@@ -384,7 +462,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"
)
}
...
...
@@ -396,7 +477,10 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
// Test bad
config
[
"iso_checksum"
]
=
""
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"
)
}
...
...
@@ -404,7 +488,10 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
// Test good
config
[
"iso_checksum"
]
=
"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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -420,7 +507,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test bad
config
[
"iso_checksum_type"
]
=
""
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"
)
}
...
...
@@ -428,7 +518,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test good
config
[
"iso_checksum_type"
]
=
"mD5"
b
=
Builder
{}
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
)
}
...
...
@@ -440,7 +533,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test unknown
config
[
"iso_checksum_type"
]
=
"fake"
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"
)
}
...
...
@@ -455,7 +551,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
// Test both epty
config
[
"iso_url"
]
=
""
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"
)
}
...
...
@@ -463,7 +562,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
// Test iso_url set
config
[
"iso_url"
]
=
"http://www.packer.io"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -477,7 +579,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
config
[
"iso_url"
]
=
"http://www.packer.io"
config
[
"iso_urls"
]
=
[]
string
{
"http://www.packer.io"
}
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"
)
}
...
...
@@ -490,7 +595,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
}
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -517,7 +625,10 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
config
[
"output_directory"
]
=
dir
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"
)
}
...
...
@@ -525,7 +636,10 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
// Test with a good one
config
[
"output_directory"
]
=
"i-hope-i-dont-exist"
b
=
Builder
{}
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
)
}
...
...
@@ -537,7 +651,10 @@ func TestBuilderPrepare_ShutdownTimeout(t *testing.T) {
// Test with a bad value
config
[
"shutdown_timeout"
]
=
"this is not good"
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"
)
}
...
...
@@ -545,7 +662,10 @@ func TestBuilderPrepare_ShutdownTimeout(t *testing.T) {
// Test with a good one
config
[
"shutdown_timeout"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -559,7 +679,10 @@ func TestBuilderPrepare_SSHHostPort(t *testing.T) {
config
[
"ssh_host_port_min"
]
=
1000
config
[
"ssh_host_port_max"
]
=
500
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"
)
}
...
...
@@ -567,7 +690,10 @@ func TestBuilderPrepare_SSHHostPort(t *testing.T) {
// Bad
config
[
"ssh_host_port_min"
]
=
-
500
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"
)
}
...
...
@@ -576,7 +702,10 @@ func TestBuilderPrepare_SSHHostPort(t *testing.T) {
config
[
"ssh_host_port_min"
]
=
500
config
[
"ssh_host_port_max"
]
=
1000
b
=
Builder
{}
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
)
}
...
...
@@ -588,14 +717,20 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
config
[
"ssh_key_path"
]
=
""
b
=
Builder
{}
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
)
}
config
[
"ssh_key_path"
]
=
"/i/dont/exist"
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"
)
}
...
...
@@ -614,7 +749,10 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
config
[
"ssh_key_path"
]
=
tf
.
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"
)
}
...
...
@@ -625,7 +763,10 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
tf
.
Write
([]
byte
(
testPem
))
config
[
"ssh_key_path"
]
=
tf
.
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
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -637,14 +778,20 @@ func TestBuilderPrepare_SSHUser(t *testing.T) {
config
[
"ssh_username"
]
=
""
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"
)
}
config
[
"ssh_username"
]
=
"exists"
b
=
Builder
{}
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
)
}
...
...
@@ -656,7 +803,10 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
// Test a default boot_wait
delete
(
config
,
"ssh_wait_timeout"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -668,7 +818,10 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
// Test with a bad value
config
[
"ssh_wait_timeout"
]
=
"this is not good"
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"
)
}
...
...
@@ -676,7 +829,10 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
// Test with a good one
config
[
"ssh_wait_timeout"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -688,7 +844,10 @@ func TestBuilderPrepare_VBoxManage(t *testing.T) {
// Test with empty
delete
(
config
,
"vboxmanage"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -703,7 +862,10 @@ func TestBuilderPrepare_VBoxManage(t *testing.T) {
}
b
=
Builder
{}
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
)
}
...
...
@@ -723,7 +885,10 @@ func TestBuilderPrepare_VBoxVersionFile(t *testing.T) {
// Test empty
delete
(
config
,
"virtualbox_version_file"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -735,7 +900,10 @@ func TestBuilderPrepare_VBoxVersionFile(t *testing.T) {
// Test with a good one
config
[
"virtualbox_version_file"
]
=
"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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
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
...
...
@@ -64,7 +64,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test a default boot_wait
delete
(
config
,
"boot_wait"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -75,7 +78,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test with a bad boot_wait
config
[
"boot_wait"
]
=
"this is not good"
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"
)
}
...
...
@@ -83,7 +89,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
// Test with a good one
config
[
"boot_wait"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -95,7 +104,10 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
// Test bad
config
[
"iso_checksum"
]
=
""
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"
)
}
...
...
@@ -103,7 +115,10 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
// Test good
config
[
"iso_checksum"
]
=
"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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -119,7 +134,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test bad
config
[
"iso_checksum_type"
]
=
""
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"
)
}
...
...
@@ -127,7 +145,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test good
config
[
"iso_checksum_type"
]
=
"mD5"
b
=
Builder
{}
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
)
}
...
...
@@ -139,7 +160,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
// Test unknown
config
[
"iso_checksum_type"
]
=
"fake"
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"
)
}
...
...
@@ -147,7 +171,10 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
func
TestBuilderPrepare_Defaults
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
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
)
}
...
...
@@ -174,7 +201,10 @@ func TestBuilderPrepare_DiskSize(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"disk_size"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -185,7 +215,10 @@ func TestBuilderPrepare_DiskSize(t *testing.T) {
config
[
"disk_size"
]
=
60000
b
=
Builder
{}
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
)
}
...
...
@@ -200,7 +233,10 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
config
:=
testConfig
()
delete
(
config
,
"floppy_files"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -211,7 +247,10 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
config
[
"floppy_files"
]
=
[]
string
{
"foo"
,
"bar"
}
b
=
Builder
{}
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
)
}
...
...
@@ -229,7 +268,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
// Bad
config
[
"http_port_min"
]
=
1000
config
[
"http_port_max"
]
=
500
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"
)
}
...
...
@@ -237,7 +279,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
// Bad
config
[
"http_port_min"
]
=
-
500
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"
)
}
...
...
@@ -246,7 +291,10 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
config
[
"http_port_min"
]
=
500
config
[
"http_port_max"
]
=
1000
b
=
Builder
{}
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
)
}
...
...
@@ -258,7 +306,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"
)
}
...
...
@@ -273,7 +324,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
// Test both epty
config
[
"iso_url"
]
=
""
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"
)
}
...
...
@@ -281,7 +335,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
// Test iso_url set
config
[
"iso_url"
]
=
"http://www.packer.io"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -295,7 +352,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
config
[
"iso_url"
]
=
"http://www.packer.io"
config
[
"iso_urls"
]
=
[]
string
{
"http://www.packer.io"
}
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"
)
}
...
...
@@ -308,7 +368,10 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
}
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warns
,
err
=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -335,7 +398,10 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
config
[
"output_directory"
]
=
dir
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"
)
}
...
...
@@ -343,7 +409,10 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
// Test with a good one
config
[
"output_directory"
]
=
"i-hope-i-dont-exist"
b
=
Builder
{}
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
)
}
...
...
@@ -355,7 +424,10 @@ func TestBuilderPrepare_ShutdownTimeout(t *testing.T) {
// Test with a bad value
config
[
"shutdown_timeout"
]
=
"this is not good"
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"
)
}
...
...
@@ -363,7 +435,10 @@ func TestBuilderPrepare_ShutdownTimeout(t *testing.T) {
// Test with a good one
config
[
"shutdown_timeout"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -375,14 +450,20 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
config
[
"ssh_key_path"
]
=
""
b
=
Builder
{}
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
)
}
config
[
"ssh_key_path"
]
=
"/i/dont/exist"
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"
)
}
...
...
@@ -401,7 +482,10 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
config
[
"ssh_key_path"
]
=
tf
.
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"
)
}
...
...
@@ -412,7 +496,10 @@ func TestBuilderPrepare_sshKeyPath(t *testing.T) {
tf
.
Write
([]
byte
(
testPem
))
config
[
"ssh_key_path"
]
=
tf
.
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
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -423,14 +510,20 @@ func TestBuilderPrepare_SSHUser(t *testing.T) {
config
:=
testConfig
()
config
[
"ssh_username"
]
=
""
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"
)
}
config
[
"ssh_username"
]
=
"exists"
b
=
Builder
{}
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
)
}
...
...
@@ -442,7 +535,10 @@ func TestBuilderPrepare_SSHPort(t *testing.T) {
// Test with a bad value
delete
(
config
,
"ssh_port"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
...
...
@@ -454,7 +550,10 @@ func TestBuilderPrepare_SSHPort(t *testing.T) {
// Test with a good one
config
[
"ssh_port"
]
=
44
b
=
Builder
{}
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
)
}
...
...
@@ -470,7 +569,10 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
// Test with a bad value
config
[
"ssh_wait_timeout"
]
=
"this is not good"
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"
)
}
...
...
@@ -478,7 +580,10 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
// Test with a good one
config
[
"ssh_wait_timeout"
]
=
"5s"
b
=
Builder
{}
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
)
}
...
...
@@ -490,7 +595,10 @@ func TestBuilderPrepare_ToolsUploadPath(t *testing.T) {
// Test a default
delete
(
config
,
"tools_upload_path"
)
err
:=
b
.
Prepare
(
config
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warns
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -502,7 +610,10 @@ func TestBuilderPrepare_ToolsUploadPath(t *testing.T) {
// Test with a bad value
config
[
"tools_upload_path"
]
=
"{{{nope}"
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"
)
}
...
...
@@ -510,7 +621,10 @@ func TestBuilderPrepare_ToolsUploadPath(t *testing.T) {
// Test with a good one
config
[
"tools_upload_path"
]
=
"hey"
b
=
Builder
{}
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
)
}
...
...
@@ -522,7 +636,10 @@ func TestBuilderPrepare_VMXTemplatePath(t *testing.T) {
// Test bad
config
[
"vmx_template_path"
]
=
"/i/dont/exist/forreal"
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"
)
}
...
...
@@ -541,7 +658,10 @@ func TestBuilderPrepare_VMXTemplatePath(t *testing.T) {
config
[
"vmx_template_path"
]
=
tf
.
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
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -560,7 +680,10 @@ func TestBuilderPrepare_VMXTemplatePath(t *testing.T) {
config
[
"vmx_template_path"
]
=
tf2
.
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"
)
}
...
...
@@ -573,7 +696,10 @@ func TestBuilderPrepare_VNCPort(t *testing.T) {
// Bad
config
[
"vnc_port_min"
]
=
1000
config
[
"vnc_port_max"
]
=
500
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"
)
}
...
...
@@ -581,7 +707,10 @@ func TestBuilderPrepare_VNCPort(t *testing.T) {
// Bad
config
[
"vnc_port_min"
]
=
-
500
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"
)
}
...
...
@@ -590,7 +719,10 @@ func TestBuilderPrepare_VNCPort(t *testing.T) {
config
[
"vnc_port_min"
]
=
500
config
[
"vnc_port_max"
]
=
1000
b
=
Builder
{}
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
)
}
...
...
@@ -605,7 +737,10 @@ func TestBuilderPrepare_VMXData(t *testing.T) {
"two"
:
"bar"
,
}
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
)
}
...
...
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