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
47b570a2
Commit
47b570a2
authored
May 23, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template/interpolate: flip disable to enableenv
parent
97a48e35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
template/interpolate/funcs.go
template/interpolate/funcs.go
+1
-1
template/interpolate/funcs_test.go
template/interpolate/funcs_test.go
+2
-2
template/interpolate/i.go
template/interpolate/i.go
+2
-2
No files found.
template/interpolate/funcs.go
View file @
47b570a2
...
@@ -51,7 +51,7 @@ func Funcs(ctx *Context) template.FuncMap {
...
@@ -51,7 +51,7 @@ func Funcs(ctx *Context) template.FuncMap {
func
funcGenEnv
(
ctx
*
Context
)
interface
{}
{
func
funcGenEnv
(
ctx
*
Context
)
interface
{}
{
return
func
(
k
string
)
(
string
,
error
)
{
return
func
(
k
string
)
(
string
,
error
)
{
if
ctx
.
Dis
ableEnv
{
if
!
ctx
.
En
ableEnv
{
// The error message doesn't have to be that detailed since
// The error message doesn't have to be that detailed since
// semantic checks should catch this.
// semantic checks should catch this.
return
""
,
errors
.
New
(
"env vars are not allowed here"
)
return
""
,
errors
.
New
(
"env vars are not allowed here"
)
...
...
template/interpolate/funcs_test.go
View file @
47b570a2
...
@@ -26,7 +26,7 @@ func TestFuncEnv(t *testing.T) {
...
@@ -26,7 +26,7 @@ func TestFuncEnv(t *testing.T) {
os
.
Setenv
(
"PACKER_TEST_ENV"
,
"foo"
)
os
.
Setenv
(
"PACKER_TEST_ENV"
,
"foo"
)
defer
os
.
Setenv
(
"PACKER_TEST_ENV"
,
""
)
defer
os
.
Setenv
(
"PACKER_TEST_ENV"
,
""
)
ctx
:=
&
Context
{}
ctx
:=
&
Context
{
EnableEnv
:
true
}
for
_
,
tc
:=
range
cases
{
for
_
,
tc
:=
range
cases
{
i
:=
&
I
{
Value
:
tc
.
Input
}
i
:=
&
I
{
Value
:
tc
.
Input
}
result
,
err
:=
i
.
Render
(
ctx
)
result
,
err
:=
i
.
Render
(
ctx
)
...
@@ -53,7 +53,7 @@ func TestFuncEnv_disable(t *testing.T) {
...
@@ -53,7 +53,7 @@ func TestFuncEnv_disable(t *testing.T) {
},
},
}
}
ctx
:=
&
Context
{
DisableEnv
:
tru
e
}
ctx
:=
&
Context
{
EnableEnv
:
fals
e
}
for
_
,
tc
:=
range
cases
{
for
_
,
tc
:=
range
cases
{
i
:=
&
I
{
Value
:
tc
.
Input
}
i
:=
&
I
{
Value
:
tc
.
Input
}
result
,
err
:=
i
.
Render
(
ctx
)
result
,
err
:=
i
.
Render
(
ctx
)
...
...
template/interpolate/i.go
View file @
47b570a2
...
@@ -15,8 +15,8 @@ type Context struct {
...
@@ -15,8 +15,8 @@ type Context struct {
// "user" function reads from.
// "user" function reads from.
UserVariables
map
[
string
]
string
UserVariables
map
[
string
]
string
//
DisableEnv dis
ables the env function
//
EnableEnv en
ables the env function
Dis
ableEnv
bool
En
ableEnv
bool
}
}
// I stands for "interpolation" and is the main interpolation struct
// I stands for "interpolation" and is the main interpolation struct
...
...
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