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
5ac06e11
Commit
5ac06e11
authored
May 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Parse "hooks" configuration into the Template
parent
44bd56c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
packer/template.go
packer/template.go
+3
-0
packer/template_test.go
packer/template_test.go
+23
-0
No files found.
packer/template.go
View file @
5ac06e11
...
...
@@ -12,6 +12,7 @@ import (
type
rawTemplate
struct
{
Name
string
Builders
[]
map
[
string
]
interface
{}
Hooks
map
[
string
][]
string
Provisioners
[]
map
[
string
]
interface
{}
Outputs
[]
map
[
string
]
interface
{}
}
...
...
@@ -21,6 +22,7 @@ type rawTemplate struct {
type
Template
struct
{
Name
string
Builders
map
[
string
]
rawBuilderConfig
Hooks
map
[
string
][]
string
}
// The rawBuilderConfig struct represents a raw, unprocessed builder
...
...
@@ -44,6 +46,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
t
=
&
Template
{}
t
.
Name
=
rawTpl
.
Name
t
.
Builders
=
make
(
map
[
string
]
rawBuilderConfig
)
t
.
Hooks
=
rawTpl
.
Hooks
for
_
,
v
:=
range
rawTpl
.
Builders
{
rawType
,
ok
:=
v
[
"type"
]
...
...
packer/template_test.go
View file @
5ac06e11
...
...
@@ -89,6 +89,29 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
assert
.
Equal
(
builder
.
builderName
,
"amazon-ebs"
,
"builder should be amazon-ebs"
)
}
func
TestParseTemplate_Hooks
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
data
:=
`
{
"name": "my-image",
"hooks": {
"event": ["foo", "bar"]
}
}
`
result
,
err
:=
ParseTemplate
([]
byte
(
data
))
assert
.
Nil
(
err
,
"should not error"
)
assert
.
NotNil
(
result
,
"template should not be nil"
)
assert
.
Length
(
result
.
Hooks
,
1
,
"should have one hook"
)
hooks
,
ok
:=
result
.
Hooks
[
"event"
]
assert
.
True
(
ok
,
"should have hook"
)
assert
.
Equal
(
hooks
,
[]
string
{
"foo"
,
"bar"
},
"hooks should be correct"
)
}
func
TestTemplate_BuildNames
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
...
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