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
d180df00
Commit
d180df00
authored
Jun 29, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Template requires builders
parent
bd8f8941
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
CHANGELOG.md
CHANGELOG.md
+1
-0
packer/template.go
packer/template.go
+4
-0
packer/template_test.go
packer/template_test.go
+12
-2
No files found.
CHANGELOG.md
View file @
d180df00
...
...
@@ -2,6 +2,7 @@
IMPROVEMENTS:
*
core: Template doesn't validate if there are no builders.
*
vmware: Delete any VMware files in the VM that aren't necessary for
it to function.
...
...
packer/template.go
View file @
d180df00
...
...
@@ -172,6 +172,10 @@ func ParseTemplate(data []byte) (t *Template, err error) {
raw
.
rawConfig
=
v
}
if
len
(
t
.
Builders
)
==
0
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"No builders are defined in the template."
))
}
// If there were errors, we put it into a MultiError and return
if
len
(
errors
)
>
0
{
err
=
&
MultiError
{
errors
}
...
...
packer/template_test.go
View file @
d180df00
...
...
@@ -11,14 +11,14 @@ func TestParseTemplate_Basic(t *testing.T) {
data
:=
`
{
"builders": []
"builders": [
{"type": "something"}
]
}
`
result
,
err
:=
ParseTemplate
([]
byte
(
data
))
assert
.
Nil
(
err
,
"should not error"
)
assert
.
NotNil
(
result
,
"template should not be nil"
)
assert
.
Length
(
result
.
Builders
,
0
,
"no builders
"
)
assert
.
Length
(
result
.
Builders
,
1
,
"one builder
"
)
}
func
TestParseTemplate_Invalid
(
t
*
testing
.
T
)
{
...
...
@@ -140,6 +140,8 @@ func TestParseTemplate_Hooks(t *testing.T) {
data
:=
`
{
"builders": [{"type": "foo"}],
"hooks": {
"event": ["foo", "bar"]
}
...
...
@@ -159,6 +161,8 @@ func TestParseTemplate_Hooks(t *testing.T) {
func
TestParseTemplate_PostProcessors
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [{"type": "foo"}],
"post-processors": [
"simple",
...
...
@@ -215,6 +219,8 @@ func TestParseTemplate_ProvisionerWithoutType(t *testing.T) {
data
:=
`
{
"builders": [{"type": "foo"}],
"provisioners": [{}]
}
`
...
...
@@ -228,6 +234,8 @@ func TestParseTemplate_ProvisionerWithNonStringType(t *testing.T) {
data
:=
`
{
"builders": [{"type": "foo"}],
"provisioners": [{
"type": 42
}]
...
...
@@ -243,6 +251,8 @@ func TestParseTemplate_Provisioners(t *testing.T) {
data
:=
`
{
"builders": [{"type": "foo"}],
"provisioners": [
{
"type": "shell"
...
...
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