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
90581899
Commit
90581899
authored
Jun 13, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
helper/config: decode time durations
parent
60081c32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
helper/config/decode.go
helper/config/decode.go
+1
-0
helper/config/decode_test.go
helper/config/decode_test.go
+4
-0
No files found.
helper/config/decode.go
View file @
90581899
...
...
@@ -66,6 +66,7 @@ func Decode(target interface{}, config *DecodeOpts, raws ...interface{}) error {
DecodeHook
:
mapstructure
.
ComposeDecodeHookFunc
(
uint8ToStringHook
,
mapstructure
.
StringToSliceHookFunc
(
","
),
mapstructure
.
StringToTimeDurationHookFunc
(),
),
})
if
err
!=
nil
{
...
...
helper/config/decode_test.go
View file @
90581899
...
...
@@ -3,6 +3,7 @@ package config
import
(
"reflect"
"testing"
"time"
"github.com/mitchellh/packer/template/interpolate"
)
...
...
@@ -11,6 +12,7 @@ func TestDecode(t *testing.T) {
type
Target
struct
{
Name
string
Address
string
Time
time
.
Duration
}
cases
:=
map
[
string
]
struct
{
...
...
@@ -22,10 +24,12 @@ func TestDecode(t *testing.T) {
[]
interface
{}{
map
[
string
]
interface
{}{
"name"
:
"bar"
,
"time"
:
"5s"
,
},
},
&
Target
{
Name
:
"bar"
,
Time
:
5
*
time
.
Second
,
},
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