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
ca70cd8f
Commit
ca70cd8f
authored
Dec 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Tempaltes understand "pause_before" in provisioners
parent
5eb16895
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
packer/template.go
packer/template.go
+19
-2
packer/template_test.go
packer/template_test.go
+33
-0
No files found.
packer/template.go
View file @
ca70cd8f
...
...
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"sort"
"time"
)
// The rawTemplate struct represents the structure of a template read
...
...
@@ -63,10 +64,13 @@ type RawPostProcessorConfig struct {
type
RawProvisionerConfig
struct
{
TemplateOnlyExcept
`mapstructure:",squash"`
Type
string
Override
map
[
string
]
interface
{}
Type
string
Override
map
[
string
]
interface
{}
RawPauseBefore
string
`mapstructure:"pause_before"`
RawConfig
interface
{}
pauseBefore
time
.
Duration
}
// RawVariable represents a variable configuration within a template.
...
...
@@ -289,6 +293,19 @@ func ParseTemplate(data []byte) (t *Template, err error) {
}
}
// Setup the pause settings
if
raw
.
RawPauseBefore
!=
""
{
duration
,
err
:=
time
.
ParseDuration
(
raw
.
RawPauseBefore
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"provisioner %d: pause_before invalid: %s"
,
i
+
1
,
err
))
}
raw
.
pauseBefore
=
duration
}
raw
.
RawConfig
=
v
}
...
...
packer/template_test.go
View file @
ca70cd8f
...
...
@@ -6,6 +6,7 @@ import (
"reflect"
"sort"
"testing"
"time"
)
func
testTemplateComponentFinder
()
*
ComponentFinder
{
...
...
@@ -445,6 +446,38 @@ func TestParseTemplate_Provisioners(t *testing.T) {
}
}
func
TestParseTemplate_ProvisionerPauseBefore
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [{"type": "foo"}],
"provisioners": [
{
"type": "shell",
"pause_before": "10s"
}
]
}
`
result
,
err
:=
ParseTemplate
([]
byte
(
data
))
if
err
!=
nil
{
t
.
Fatal
(
"err: %s"
,
err
)
}
if
result
==
nil
{
t
.
Fatal
(
"should have result"
)
}
if
len
(
result
.
Provisioners
)
!=
1
{
t
.
Fatalf
(
"bad: %#v"
,
result
.
Provisioners
)
}
if
result
.
Provisioners
[
0
]
.
Type
!=
"shell"
{
t
.
Fatalf
(
"bad: %#v"
,
result
.
Provisioners
[
0
]
.
Type
)
}
if
result
.
Provisioners
[
0
]
.
pauseBefore
!=
10
*
time
.
Second
{
t
.
Fatalf
(
"bad: %s"
,
result
.
Provisioners
[
0
]
.
pauseBefore
)
}
}
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