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
8e617d00
Commit
8e617d00
authored
Dec 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Add description to top-level template [GH-658]
parent
fe22308a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
packer/template.go
packer/template.go
+3
-0
packer/template_test.go
packer/template_test.go
+20
-0
No files found.
packer/template.go
View file @
8e617d00
...
...
@@ -16,6 +16,7 @@ import (
// "interface{}" pointers since we actually don't know what their contents
// are until we read the "type" field.
type
rawTemplate
struct
{
Description
string
Variables
map
[
string
]
interface
{}
Builders
[]
map
[
string
]
interface
{}
Hooks
map
[
string
][]
string
...
...
@@ -26,6 +27,7 @@ type rawTemplate struct {
// The Template struct represents a parsed template, parsed into the most
// completed form it can be without additional processing by the caller.
type
Template
struct
{
Description
string
Variables
map
[
string
]
RawVariable
Builders
map
[
string
]
RawBuilderConfig
Hooks
map
[
string
][]
string
...
...
@@ -115,6 +117,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
}
t
=
&
Template
{}
t
.
Description
=
rawTpl
.
Description
t
.
Variables
=
make
(
map
[
string
]
RawVariable
)
t
.
Builders
=
make
(
map
[
string
]
RawBuilderConfig
)
t
.
Hooks
=
rawTpl
.
Hooks
...
...
packer/template_test.go
View file @
8e617d00
...
...
@@ -111,6 +111,26 @@ func TestParseTemplate_Basic(t *testing.T) {
}
}
func
TestParseTemplate_Description
(
t
*
testing
.
T
)
{
data
:=
`
{
"description": "Foo",
"builders": [{"type": "something"}]
}
`
result
,
err
:=
ParseTemplate
([]
byte
(
data
))
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
result
==
nil
{
t
.
Fatal
(
"should have result"
)
}
if
result
.
Description
!=
"Foo"
{
t
.
Fatalf
(
"bad: %#v"
,
result
.
Description
)
}
}
func
TestParseTemplate_Invalid
(
t
*
testing
.
T
)
{
// Note there is an extra comma below for a purposeful
// syntax error in the JSON.
...
...
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