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
9239b6a2
Commit
9239b6a2
authored
Dec 26, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: {{timestamp}} is the same for an entire build [GH-744]
parent
366d1693
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
CHANGELOG.md
CHANGELOG.md
+2
-0
packer/config_template.go
packer/config_template.go
+10
-1
packer/config_template_test.go
packer/config_template_test.go
+11
-0
No files found.
CHANGELOG.md
View file @
9239b6a2
...
...
@@ -61,6 +61,8 @@ BUG FIXES:
*
core: User variables can now be used for non-string fields. [GH-598]
*
core: Fix bad download paths if the download URL contained a "."
before a "/" [GH-716]
*
core: "{{timestamp}}" values will always be the same for the entire
duration of a build. [GH-744]
*
builder/virtualbox: don't download guest additions if disabled. [GH-731]
*
post-processor/vsphere: Uploads VM properly. [GH-694]
*
post-processor/vsphere: Process user variables.
...
...
packer/config_template.go
View file @
9239b6a2
...
...
@@ -9,6 +9,15 @@ import (
"time"
)
// InitTime is the UTC time when this package was initialized. It is
// used as the timestamp for all configuration templates so that they
// match for a single build.
var
InitTime
time
.
Time
func
init
()
{
InitTime
=
time
.
Now
()
.
UTC
()
}
// ConfigTemplate processes string data as a text/template with some common
// elements and functions available. Plugin creators should process as
// many fields as possible through this.
...
...
@@ -89,7 +98,7 @@ func templateISOTime() string {
}
func
templateTimestamp
()
string
{
return
strconv
.
FormatInt
(
time
.
Now
()
.
UTC
()
.
Unix
(),
10
)
return
strconv
.
FormatInt
(
InitTime
.
Unix
(),
10
)
}
func
templateUuid
()
string
{
...
...
packer/config_template_test.go
View file @
9239b6a2
...
...
@@ -49,6 +49,17 @@ func TestConfigTemplateProcess_timestamp(t *testing.T) {
if
math
.
Abs
(
float64
(
currentTime
-
val
))
>
10
{
t
.
Fatalf
(
"val: %d (current: %d)"
,
val
,
currentTime
)
}
time
.
Sleep
(
2
*
time
.
Second
)
result2
,
err
:=
tpl
.
Process
(
`{{timestamp}}`
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
result
!=
result2
{
t
.
Fatalf
(
"bad: %#v %#v"
,
result
,
result2
)
}
}
func
TestConfigTemplateProcess_user
(
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