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
9acaa97a
Commit
9acaa97a
authored
Nov 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox,vmware: warning if shutdown_command is not specified
parent
87e88dc8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
+53
-5
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+11
-3
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+16
-0
builder/vmware/builder.go
builder/vmware/builder.go
+10
-2
builder/vmware/builder_test.go
builder/vmware/builder_test.go
+16
-0
No files found.
builder/virtualbox/builder.go
View file @
9acaa97a
...
...
@@ -84,8 +84,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
// Accumulate any errors
// Accumulate any errors
and warnings
errs
:=
common
.
CheckUnusedConfig
(
md
)
warnings
:=
make
([]
string
,
0
)
if
b
.
config
.
DiskSize
==
0
{
b
.
config
.
DiskSize
=
40000
...
...
@@ -363,11 +364,18 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
}
}
// Warnings
if
b
.
config
.
ShutdownCommand
==
""
{
warnings
=
append
(
warnings
,
"A shutdown_command was not specified. Without a shutdown command, Packer
\n
"
+
"will forcibly halt the virtual machine, which may result in data loss."
)
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
nil
,
errs
return
warnings
,
errs
}
return
nil
,
nil
return
warnings
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/virtualbox/builder_test.go
View file @
9acaa97a
...
...
@@ -43,6 +43,7 @@ func testConfig() map[string]interface{} {
"iso_checksum"
:
"foo"
,
"iso_checksum_type"
:
"md5"
,
"iso_url"
:
"http://www.google.com/"
,
"shutdown_command"
:
"yes"
,
"ssh_username"
:
"foo"
,
packer
.
BuildNameConfigKey
:
"foo"
,
...
...
@@ -645,6 +646,21 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
}
}
func
TestBuilderPrepare_ShutdownCommand
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
delete
(
config
,
"shutdown_command"
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
if
len
(
warns
)
!=
1
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
}
func
TestBuilderPrepare_ShutdownTimeout
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/vmware/builder.go
View file @
9acaa97a
...
...
@@ -80,6 +80,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
warnings
:=
make
([]
string
,
0
)
if
b
.
config
.
DiskName
==
""
{
b
.
config
.
DiskName
=
"disk"
...
...
@@ -326,11 +327,18 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs
,
fmt
.
Errorf
(
"vnc_port_min must be less than vnc_port_max"
))
}
// Warnings
if
b
.
config
.
ShutdownCommand
==
""
{
warnings
=
append
(
warnings
,
"A shutdown_command was not specified. Without a shutdown command, Packer
\n
"
+
"will forcibly halt the virtual machine, which may result in data loss."
)
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
nil
,
errs
return
warnings
,
errs
}
return
nil
,
nil
return
warnings
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/vmware/builder_test.go
View file @
9acaa97a
...
...
@@ -44,6 +44,7 @@ func testConfig() map[string]interface{} {
"iso_checksum"
:
"foo"
,
"iso_checksum_type"
:
"md5"
,
"iso_url"
:
"http://www.packer.io"
,
"shutdown_command"
:
"foo"
,
"ssh_username"
:
"foo"
,
packer
.
BuildNameConfigKey
:
"foo"
,
...
...
@@ -418,6 +419,21 @@ func TestBuilderPrepare_OutputDir(t *testing.T) {
}
}
func
TestBuilderPrepare_ShutdownCommand
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
delete
(
config
,
"shutdown_command"
)
warns
,
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %s"
,
err
)
}
if
len
(
warns
)
!=
1
{
t
.
Fatalf
(
"bad: %#v"
,
warns
)
}
}
func
TestBuilderPrepare_ShutdownTimeout
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
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