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
4a5721fb
Commit
4a5721fb
authored
Mar 21, 2017
by
Justin Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixup style and errors
parent
007bb9db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
requirements.go
pkg/chartutil/requirements.go
+32
-32
No files found.
pkg/chartutil/requirements.go
View file @
4a5721fb
...
@@ -269,15 +269,20 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
...
@@ -269,15 +269,20 @@ func ProcessRequirementsEnabled(c *chart.Chart, v *chart.Config) error {
return
nil
return
nil
}
}
// pathToMap creates a nested map given a YAML path in dot notation
// pathToMap creates a nested map given a YAML path in dot notation
.
func
pathToMap
(
path
string
,
data
map
[
string
]
interface
{})
map
[
string
]
interface
{}
{
func
pathToMap
(
path
string
,
data
map
[
string
]
interface
{})
map
[
string
]
interface
{}
{
ap
:=
strings
.
Split
(
path
,
"."
)
ap
:=
strings
.
Split
(
path
,
"."
)
if
len
(
ap
)
==
0
{
return
nil
}
n
:=
[]
map
[
string
]
interface
{}{}
n
:=
[]
map
[
string
]
interface
{}{}
// created nested map for each key, adding to slice
for
_
,
v
:=
range
ap
{
for
_
,
v
:=
range
ap
{
nm
:=
make
(
map
[
string
]
interface
{})
nm
:=
make
(
map
[
string
]
interface
{})
nm
[
v
]
=
make
(
map
[
string
]
interface
{})
nm
[
v
]
=
make
(
map
[
string
]
interface
{})
n
=
append
(
n
,
nm
)
n
=
append
(
n
,
nm
)
}
}
// find the last key (map) and set our data
for
i
,
d
:=
range
n
{
for
i
,
d
:=
range
n
{
for
k
:=
range
d
{
for
k
:=
range
d
{
z
:=
i
+
1
z
:=
i
+
1
...
@@ -292,11 +297,10 @@ func pathToMap(path string, data map[string]interface{}) map[string]interface{}
...
@@ -292,11 +297,10 @@ func pathToMap(path string, data map[string]interface{}) map[string]interface{}
return
n
[
0
]
return
n
[
0
]
}
}
// getParents returns a slice of parent charts in reverse order
// getParents returns a slice of parent charts in reverse order
.
func
getParents
(
c
*
chart
.
Chart
,
out
[]
*
chart
.
Chart
)
[]
*
chart
.
Chart
{
func
getParents
(
c
*
chart
.
Chart
,
out
[]
*
chart
.
Chart
)
[]
*
chart
.
Chart
{
if
len
(
out
)
==
0
{
if
len
(
out
)
==
0
{
out
=
[]
*
chart
.
Chart
{}
out
=
[]
*
chart
.
Chart
{
c
}
out
=
append
(
out
,
c
)
}
}
for
_
,
ch
:=
range
c
.
Dependencies
{
for
_
,
ch
:=
range
c
.
Dependencies
{
if
len
(
ch
.
Dependencies
)
>
0
{
if
len
(
ch
.
Dependencies
)
>
0
{
...
@@ -308,16 +312,15 @@ func getParents(c *chart.Chart, out []*chart.Chart) []*chart.Chart {
...
@@ -308,16 +312,15 @@ func getParents(c *chart.Chart, out []*chart.Chart) []*chart.Chart {
return
out
return
out
}
}
// processImportValues merges values from child to parent based on ImportValues field
// processImportValues merges values from child to parent based on ImportValues field
.
func
processImportValues
(
c
*
chart
.
Chart
,
v
*
chart
.
Config
)
error
{
func
processImportValues
(
c
*
chart
.
Chart
,
v
*
chart
.
Config
)
error
{
reqs
,
err
:=
LoadRequirements
(
c
)
reqs
,
err
:=
LoadRequirements
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"Warning: ImportValues cannot load requirements for %s"
,
c
.
Metadata
.
Name
)
return
err
return
nil
}
}
cvals
,
err
:=
CoalesceValues
(
c
,
v
)
cvals
,
err
:=
CoalesceValues
(
c
,
v
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Error coalescing values for ImportValues %s"
,
err
)
return
err
}
}
nv
:=
v
.
GetValues
()
nv
:=
v
.
GetValues
()
b
:=
make
(
map
[
string
]
interface
{})
b
:=
make
(
map
[
string
]
interface
{})
...
@@ -328,30 +331,29 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
...
@@ -328,30 +331,29 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
if
len
(
r
.
ImportValues
)
>
0
{
if
len
(
r
.
ImportValues
)
>
0
{
var
outiv
[]
interface
{}
var
outiv
[]
interface
{}
for
_
,
riv
:=
range
r
.
ImportValues
{
for
_
,
riv
:=
range
r
.
ImportValues
{
switch
riv
.
(
type
)
{
switch
iv
:=
riv
.
(
type
)
{
case
map
[
string
]
interface
{}
:
case
map
[
string
]
interface
{}
:
if
m
,
ok
:=
riv
.
(
map
[
string
]
interface
{});
ok
{
nm
:=
map
[
string
]
string
{
nm
:=
make
(
map
[
string
]
string
)
"child"
:
iv
[
"child"
]
.
(
string
),
nm
[
"child"
]
=
m
[
"child"
]
.
(
string
)
"parent"
:
iv
[
"parent"
]
.
(
string
),
nm
[
"parent"
]
=
m
[
"parent"
]
.
(
string
)
}
outiv
=
append
(
outiv
,
nm
)
outiv
=
append
(
outiv
,
nm
)
s
:=
r
.
Name
+
"."
+
nm
[
"child"
]
s
:=
r
.
Name
+
"."
+
nm
[
"child"
]
vv
,
err
:=
cvals
.
Table
(
s
)
vv
,
err
:=
cvals
.
Table
(
s
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"Warning: ImportValues missing table %v"
,
err
)
log
.
Printf
(
"Warning: ImportValues missing table %v"
,
err
)
continue
continue
}
}
if
nm
[
"parent"
]
==
"."
{
if
nm
[
"parent"
]
==
"."
{
coalesceTables
(
b
,
vv
.
AsMap
())
coalesceTables
(
b
,
vv
.
AsMap
())
}
else
{
}
else
{
vm
:=
pathToMap
(
nm
[
"parent"
],
vv
.
AsMap
())
vm
:=
pathToMap
(
nm
[
"parent"
],
vv
.
AsMap
())
coalesceTables
(
b
,
vm
)
coalesceTables
(
b
,
vm
)
}
}
}
case
string
:
case
string
:
nm
:=
make
(
map
[
string
]
string
)
nm
:=
make
(
map
[
string
]
string
)
nm
[
"child"
]
=
"exports."
+
riv
.
(
string
)
nm
[
"child"
]
=
"exports."
+
iv
nm
[
"parent"
]
=
"."
nm
[
"parent"
]
=
"."
outiv
=
append
(
outiv
,
nm
)
outiv
=
append
(
outiv
,
nm
)
s
:=
r
.
Name
+
"."
+
nm
[
"child"
]
s
:=
r
.
Name
+
"."
+
nm
[
"child"
]
...
@@ -367,14 +369,13 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
...
@@ -367,14 +369,13 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
r
.
ImportValues
=
outiv
r
.
ImportValues
=
outiv
}
}
}
}
cv
,
err
:=
coalesceValues
(
c
,
b
)
cv
,
err
:=
coalesceValues
(
c
,
b
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Error coalescing processed values for ImportValues %s"
,
err
)
return
err
}
}
y
,
err
:=
yaml
.
Marshal
(
cv
)
y
,
err
:=
yaml
.
Marshal
(
cv
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"Warning: ImportValues could not marshall %v"
,
err
)
return
err
}
}
bb
:=
&
chart
.
Config
{
Raw
:
string
(
y
)}
bb
:=
&
chart
.
Config
{
Raw
:
string
(
y
)}
v
=
bb
v
=
bb
...
@@ -383,12 +384,11 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
...
@@ -383,12 +384,11 @@ func processImportValues(c *chart.Chart, v *chart.Config) error {
return
nil
return
nil
}
}
// ProcessRequirementsImportValues imports specified chart values from child to parent
// ProcessRequirementsImportValues imports specified chart values from child to parent
.
func
ProcessRequirementsImportValues
(
c
*
chart
.
Chart
,
v
*
chart
.
Config
)
error
{
func
ProcessRequirementsImportValues
(
c
*
chart
.
Chart
,
v
*
chart
.
Config
)
error
{
pc
:=
getParents
(
c
,
nil
)
pc
:=
getParents
(
c
,
nil
)
for
i
:=
len
(
pc
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
pc
)
-
1
;
i
>=
0
;
i
--
{
processImportValues
(
pc
[
i
],
v
)
processImportValues
(
pc
[
i
],
v
)
}
}
return
nil
return
nil
...
...
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