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
835cadee
Commit
835cadee
authored
Oct 28, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: push configuration
parent
76a09e02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
packer/template.go
packer/template.go
+11
-0
packer/template_test.go
packer/template_test.go
+35
-0
No files found.
packer/template.go
View file @
835cadee
...
...
@@ -24,6 +24,7 @@ type rawTemplate struct {
Description
string
Builders
[]
map
[
string
]
interface
{}
Hooks
map
[
string
][]
string
Push
PushConfig
PostProcessors
[]
interface
{}
`mapstructure:"post-processors"`
Provisioners
[]
map
[
string
]
interface
{}
Variables
map
[
string
]
interface
{}
...
...
@@ -36,10 +37,19 @@ type Template struct {
Variables
map
[
string
]
RawVariable
Builders
map
[
string
]
RawBuilderConfig
Hooks
map
[
string
][]
string
Push
*
PushConfig
PostProcessors
[][]
RawPostProcessorConfig
Provisioners
[]
RawProvisionerConfig
}
// PushConfig is the configuration structure for the push settings.
type
PushConfig
struct
{
Name
string
Include
[]
string
Exclude
[]
string
VCS
bool
}
// The RawBuilderConfig struct represents a raw, unprocessed builder
// configuration. It contains the name of the builder as well as the
// raw configuration. If requested, this is used to compile into a full
...
...
@@ -154,6 +164,7 @@ func ParseTemplate(data []byte, vars map[string]string) (t *Template, err error)
t
.
Variables
=
make
(
map
[
string
]
RawVariable
)
t
.
Builders
=
make
(
map
[
string
]
RawBuilderConfig
)
t
.
Hooks
=
rawTpl
.
Hooks
t
.
Push
=
&
rawTpl
.
Push
t
.
PostProcessors
=
make
([][]
RawPostProcessorConfig
,
len
(
rawTpl
.
PostProcessors
))
t
.
Provisioners
=
make
([]
RawProvisionerConfig
,
len
(
rawTpl
.
Provisioners
))
...
...
packer/template_test.go
View file @
835cadee
...
...
@@ -541,6 +541,41 @@ func TestParseTemplate_ProvisionerPauseBefore(t *testing.T) {
}
}
func
TestParseTemplateFile_push
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [{"type": "something"}],
"push": {
"name": "hello",
"include": ["one"],
"exclude": ["two"]
}
}
`
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
tf
.
Write
([]
byte
(
data
))
tf
.
Close
()
result
,
err
:=
ParseTemplateFile
(
tf
.
Name
(),
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
expected
:=
&
PushConfig
{
Name
:
"hello"
,
Include
:
[]
string
{
"one"
},
Exclude
:
[]
string
{
"two"
},
}
if
!
reflect
.
DeepEqual
(
result
.
Push
,
expected
)
{
t
.
Fatalf
(
"bad: %#v"
,
result
.
Push
)
}
}
func
TestParseTemplate_Variables
(
t
*
testing
.
T
)
{
data
:=
`
{
...
...
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