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
0486a907
Commit
0486a907
authored
Jun 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: error if output directory exists
parent
1400d20b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
builder/vmware/builder.go
builder/vmware/builder.go
+4
-0
builder/vmware/builder_test.go
builder/vmware/builder_test.go
+25
-0
No files found.
builder/vmware/builder.go
View file @
0486a907
...
...
@@ -155,6 +155,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if
_
,
err
:=
os
.
Stat
(
b
.
config
.
OutputDir
);
err
==
nil
{
errs
=
append
(
errs
,
errors
.
New
(
"Output directory already exists. It must not exist."
))
}
if
b
.
config
.
SSHUser
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"An ssh_username must be specified."
))
}
...
...
builder/vmware/builder_test.go
View file @
0486a907
...
...
@@ -190,6 +190,31 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
}
}
func
TestBuilderPrepare_OutputDir
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test with existing dir
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
RemoveAll
(
dir
)
config
[
"output_directory"
]
=
dir
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Test with a good one
config
[
"output_directory"
]
=
"i-hope-i-dont-exist"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
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