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
4fa27e6a
Commit
4fa27e6a
authored
Jun 08, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazonebs: Finish basic validation
parent
4223e5bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+4
-3
builder/amazonebs/builder_test.go
builder/amazonebs/builder_test.go
+25
-0
No files found.
builder/amazonebs/builder.go
View file @
4fa27e6a
...
...
@@ -68,6 +68,10 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
errs
=
append
(
errs
,
errors
.
New
(
"An instance_type must be specified"
))
}
if
b
.
config
.
Region
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"A region must be specified"
))
}
if
b
.
config
.
SSHUsername
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"An ssh_username must be specified"
))
}
...
...
@@ -76,9 +80,6 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
return
&
packer
.
MultiError
{
errs
}
}
// TODO: config validation and asking for fields:
// * region (exists and valid)
log
.
Printf
(
"Config: %+v"
,
b
.
config
)
return
}
...
...
builder/amazonebs/builder_test.go
View file @
4fa27e6a
...
...
@@ -11,6 +11,7 @@ func testConfig() map[string]interface{} {
"secret_key"
:
"bar"
,
"source_ami"
:
"foo"
,
"instance_type"
:
"foo"
,
"region"
:
"foo"
,
"ssh_username"
:
"root"
,
}
}
...
...
@@ -83,6 +84,30 @@ func TestBuilderPrepare_InstanceType(t *testing.T) {
}
}
func
TestBuilderPrepare_Region
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test good
config
[
"region"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
Region
!=
"foo"
{
t
.
Errorf
(
"invalid: %s"
,
b
.
config
.
Region
)
}
// Test bad
delete
(
config
,
"region"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
}
func
TestBuilderPrepare_SecretKey
(
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