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
07312c68
Commit
07312c68
authored
Apr 21, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(engine): support chart template recursion
parent
60779683
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
engine.go
pkg/engine/engine.go
+7
-4
engine_test.go
pkg/engine/engine_test.go
+14
-5
No files found.
pkg/engine/engine.go
View file @
07312c68
...
...
@@ -104,13 +104,16 @@ func (e *Engine) render(tpls map[string]string, v interface{}) (map[string]strin
// allTemplates returns all templates for a chart and its dependencies.
func
allTemplates
(
c
*
chart
.
Chart
)
map
[
string
]
string
{
templates
:=
map
[
string
]
string
{}
recAllTpls
(
c
,
templates
)
return
templates
}
func
recAllTpls
(
c
*
chart
.
Chart
,
templates
map
[
string
]
string
)
{
for
_
,
child
:=
range
c
.
Dependencies
{
for
_
,
t
:=
range
child
.
Templates
{
templates
[
t
.
Name
]
=
string
(
t
.
Data
)
}
recAllTpls
(
child
,
templates
)
}
for
_
,
t
:=
range
c
.
Templates
{
templates
[
t
.
Name
]
=
string
(
t
.
Data
)
}
return
templates
}
pkg/engine/engine_test.go
View file @
07312c68
...
...
@@ -90,16 +90,23 @@ func TestAllTemplates(t *testing.T) {
{
Name
:
"bar"
,
Data
:
[]
byte
(
"bar"
)},
},
Dependencies
:
[]
*
chart
.
Chart
{
{
Templates
:
[]
*
chart
.
Template
{
{
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"pinky"
,
Data
:
[]
byte
(
"pinky"
)},
{
Name
:
"brain"
,
Data
:
[]
byte
(
"brain"
)},
},
Dependencies
:
[]
*
chart
.
Chart
{
{
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"innermost"
,
Data
:
[]
byte
(
"innermost"
)},
}},
},
},
},
}
tpls
:=
allTemplates
(
ch1
)
if
len
(
tpls
)
!=
4
{
t
.
Errorf
(
"Expected
4
charts, got %d"
,
len
(
tpls
))
if
len
(
tpls
)
!=
5
{
t
.
Errorf
(
"Expected
5
charts, got %d"
,
len
(
tpls
))
}
}
...
...
@@ -112,9 +119,11 @@ func TestRenderDependency(t *testing.T) {
{
Name
:
"outer"
,
Data
:
[]
byte
(
toptpl
)},
},
Dependencies
:
[]
*
chart
.
Chart
{
{
Templates
:
[]
*
chart
.
Template
{
{
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"inner"
,
Data
:
[]
byte
(
deptpl
)},
}},
},
},
},
}
...
...
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