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
d5981c69
Commit
d5981c69
authored
Apr 27, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: config strings to slices [GH-950]
parent
edcb8fea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
CHANGELOG.md
CHANGELOG.md
+3
-0
common/config.go
common/config.go
+4
-1
common/config_test.go
common/config_test.go
+27
-0
No files found.
CHANGELOG.md
View file @
d5981c69
...
...
@@ -14,6 +14,9 @@ FEATURES:
IMPROVEMENTS:
*
core: RPC transport between plugins switched to MessagePack
*
core: Templates array values can now be comma separated strings.
Most importantly, this allows for user variables to fill
array configurations. [GH-950]
*
builder/amazon: Added
`ssh_private_key_file`
option [GH-971]
*
builder/amazon: Added
`ami_virtualization_type`
option [GH-1021]
*
builder/googlecompute: Configurable instance name. [GH-1065]
...
...
common/config.go
View file @
d5981c69
...
...
@@ -68,7 +68,10 @@ func DecodeConfig(target interface{}, raws ...interface{}) (*mapstructure.Metada
var
md
mapstructure
.
Metadata
decoderConfig
:=
&
mapstructure
.
DecoderConfig
{
DecodeHook
:
decodeHook
,
DecodeHook
:
mapstructure
.
ComposeDecodeHookFunc
(
decodeHook
,
mapstructure
.
StringToSliceHookFunc
(
","
),
),
Metadata
:
&
md
,
Result
:
target
,
WeaklyTypedInput
:
true
,
...
...
common/config_test.go
View file @
d5981c69
...
...
@@ -95,6 +95,33 @@ func TestDecodeConfig(t *testing.T) {
}
}
// This test tests the case that a user var is used for an integer
// configuration.
func
TestDecodeConfig_stringToSlice
(
t
*
testing
.
T
)
{
type
Local
struct
{
Val
[]
string
}
raw
:=
map
[
string
]
interface
{}{
"packer_user_variables"
:
map
[
string
]
string
{
"foo"
:
"bar"
,
},
"val"
:
"foo,{{user `foo`}}"
,
}
var
result
Local
_
,
err
:=
DecodeConfig
(
&
result
,
raw
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
expected
:=
[]
string
{
"foo"
,
"bar"
}
if
!
reflect
.
DeepEqual
(
result
.
Val
,
expected
)
{
t
.
Fatalf
(
"invalid: %#v"
,
result
.
Val
)
}
}
// This test tests the case that a user var is used for an integer
// configuration.
func
TestDecodeConfig_userVarConversion
(
t
*
testing
.
T
)
{
...
...
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