Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
2c338db1
Unverified
Commit
2c338db1
authored
Oct 24, 2017
by
Lukas Eichler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(helm): Set template context inside tpl function to outer function.
docs(helm): Added documentation about tpl function
parent
16571305
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
engine.go
pkg/engine/engine.go
+17
-4
No files found.
pkg/engine/engine.go
View file @
2c338db1
...
...
@@ -166,19 +166,32 @@ func (e *Engine) alterFuncMap(t *template.Template) template.FuncMap {
// Add the 'tpl' function here
funcMap
[
"tpl"
]
=
func
(
tpl
string
,
vals
chartutil
.
Values
)
(
string
,
error
)
{
basePath
,
err
:=
vals
.
PathValue
(
"Template.BasePath"
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Cannot retrieve Template.Basepath from values inside tpl function"
,
tpl
,
err
.
Error
())
}
r
:=
renderable
{
tpl
:
tpl
,
vals
:
vals
,
tpl
:
tpl
,
vals
:
vals
,
basePath
:
basePath
.
(
string
),
}
println
(
vals
.
Table
)
templates
:=
map
[
string
]
renderable
{}
templates
[
"aaa_template"
]
=
r
templateName
,
err
:=
vals
.
PathValue
(
"Template.Name"
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Cannot retrieve Template.Name from values inside tpl function"
,
tpl
,
err
.
Error
())
}
templates
[
templateName
.
(
string
)]
=
r
result
,
err
:=
e
.
render
(
templates
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Error during tpl function execution for %q: %s"
,
tpl
,
err
.
Error
())
}
return
result
[
"aaa_template"
],
nil
return
result
[
templateName
.
(
string
)
],
nil
}
return
funcMap
...
...
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