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
5ff86ae1
Commit
5ff86ae1
authored
Jun 30, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2367 from mitchellh/b-build-type
helper/config: copy buildname/buildtype properly
parents
8fd673ff
ac444acc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
helper/config/decode.go
helper/config/decode.go
+2
-0
helper/config/decode_test.go
helper/config/decode_test.go
+30
-0
template/interpolate/funcs.go
template/interpolate/funcs.go
+1
-1
No files found.
helper/config/decode.go
View file @
5ff86ae1
...
...
@@ -42,6 +42,8 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error {
if
config
.
InterpolateContext
==
nil
{
config
.
InterpolateContext
=
ctx
}
else
{
config
.
InterpolateContext
.
BuildName
=
ctx
.
BuildName
config
.
InterpolateContext
.
BuildType
=
ctx
.
BuildType
config
.
InterpolateContext
.
TemplatePath
=
ctx
.
TemplatePath
config
.
InterpolateContext
.
UserVariables
=
ctx
.
UserVariables
}
...
...
helper/config/decode_test.go
View file @
5ff86ae1
...
...
@@ -74,6 +74,36 @@ func TestDecode(t *testing.T) {
},
},
},
"build name"
:
{
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"{{build_name}}"
,
},
map
[
string
]
interface
{}{
"packer_build_name"
:
"foo"
,
},
},
&
Target
{
Name
:
"foo"
,
},
nil
,
},
"build type"
:
{
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"{{build_type}}"
,
},
map
[
string
]
interface
{}{
"packer_builder_type"
:
"foo"
,
},
},
&
Target
{
Name
:
"foo"
,
},
nil
,
},
}
for
k
,
tc
:=
range
cases
{
...
...
template/interpolate/funcs.go
View file @
5ff86ae1
...
...
@@ -71,7 +71,7 @@ func funcGenBuildName(ctx *Context) interface{} {
func
funcGenBuildType
(
ctx
*
Context
)
interface
{}
{
return
func
()
(
string
,
error
)
{
if
ctx
==
nil
||
ctx
.
BuildType
==
""
{
return
""
,
errors
.
New
(
"build_
nam
e not available"
)
return
""
,
errors
.
New
(
"build_
typ
e not available"
)
}
return
ctx
.
BuildType
,
nil
...
...
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