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
a4b5e08f
Commit
a4b5e08f
authored
May 15, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template/interpolate: upper/lower
parent
7659a914
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
template/interpolate/funcs.go
template/interpolate/funcs.go
+19
-0
No files found.
template/interpolate/funcs.go
View file @
a4b5e08f
...
@@ -5,8 +5,11 @@ import (
...
@@ -5,8 +5,11 @@ import (
"fmt"
"fmt"
"os"
"os"
"strconv"
"strconv"
"strings"
"text/template"
"text/template"
"time"
"time"
"github.com/mitchellh/packer/common/uuid"
)
)
// InitTime is the UTC time when this package was initialized. It is
// InitTime is the UTC time when this package was initialized. It is
...
@@ -24,7 +27,11 @@ var FuncGens = map[string]FuncGenerator{
...
@@ -24,7 +27,11 @@ var FuncGens = map[string]FuncGenerator{
"isotime"
:
funcGenIsotime
,
"isotime"
:
funcGenIsotime
,
"pwd"
:
funcGenPwd
,
"pwd"
:
funcGenPwd
,
"timestamp"
:
funcGenTimestamp
,
"timestamp"
:
funcGenTimestamp
,
"uuid"
:
funcGenUuid
,
"user"
:
funcGenUser
,
"user"
:
funcGenUser
,
"upper"
:
funcGenPrimitive
(
strings
.
ToUpper
),
"lower"
:
funcGenPrimitive
(
strings
.
ToLower
),
}
}
// FuncGenerator is a function that given a context generates a template
// FuncGenerator is a function that given a context generates a template
...
@@ -68,6 +75,12 @@ func funcGenIsotime(ctx *Context) interface{} {
...
@@ -68,6 +75,12 @@ func funcGenIsotime(ctx *Context) interface{} {
}
}
}
}
func
funcGenPrimitive
(
value
interface
{})
FuncGenerator
{
return
func
(
ctx
*
Context
)
interface
{}
{
return
value
}
}
func
funcGenPwd
(
ctx
*
Context
)
interface
{}
{
func
funcGenPwd
(
ctx
*
Context
)
interface
{}
{
return
func
()
(
string
,
error
)
{
return
func
()
(
string
,
error
)
{
return
os
.
Getwd
()
return
os
.
Getwd
()
...
@@ -85,3 +98,9 @@ func funcGenUser(ctx *Context) interface{} {
...
@@ -85,3 +98,9 @@ func funcGenUser(ctx *Context) interface{} {
return
""
return
""
}
}
}
}
func
funcGenUuid
(
ctx
*
Context
)
interface
{}
{
return
func
()
string
{
return
uuid
.
TimeOrderedUUID
()
}
}
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