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
84dc6c9e
Commit
84dc6c9e
authored
Apr 07, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load resources from non template charts
parent
b5871d7a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
expander.go
cmd/manager/manager/expander.go
+28
-5
kubernetesutil.go
pkg/util/kubernetesutil.go
+9
-3
No files found.
cmd/manager/manager/expander.go
View file @
84dc6c9e
...
...
@@ -90,14 +90,15 @@ func (e *expander) expandConfiguration(conf *common.Configuration) (*ExpandedCon
}
defer
cbr
.
Close
()
expander
:=
cbr
.
Chartfile
()
.
Expander
if
expander
!=
nil
&&
expander
.
Name
!=
""
{
// Load the charts contents into strings that we can pass to exapnsion
content
,
err
:=
cbr
.
LoadContent
()
if
err
!=
nil
{
return
nil
,
err
}
expander
:=
cbr
.
Chartfile
()
.
Expander
if
expander
!=
nil
&&
expander
.
Name
!=
""
{
// Build a request to the expansion service and call it to do the expansion
svcReq
:=
&
expansion
.
ServiceRequest
{
ChartInvocation
:
resource
,
...
...
@@ -120,8 +121,28 @@ func (e *expander) expandConfiguration(conf *common.Configuration) (*ExpandedCon
// This was not a primitive resource, so add its properties to the layout
// Then add the all of the layout resources returned by the recursion to the layout
layout
.
Properties
=
resource
.
Properties
layout
.
Resources
=
expConf
.
Layout
.
Resources
layout
.
Properties
=
resource
.
Properties
}
else
{
// Raise an error if a non template chart supplies properties
if
resource
.
Properties
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"properties provided for non template chart %s"
,
resource
.
Type
)
}
additions
=
[]
*
common
.
Resource
{}
for
_
,
member
:=
range
content
.
Members
{
segments
:=
strings
.
Split
(
member
.
Path
,
"/"
)
if
len
(
segments
)
>
1
&&
segments
[
0
]
==
"templates"
{
if
strings
.
HasSuffix
(
member
.
Path
,
"yaml"
)
||
strings
.
HasSuffix
(
member
.
Path
,
"json"
)
{
resource
,
err
:=
util
.
ParseKubernetesObject
(
member
.
Content
)
if
err
!=
nil
{
return
nil
,
err
}
resources
=
append
(
resources
,
resource
)
}
}
}
}
}
...
...
@@ -130,10 +151,12 @@ func (e *expander) expandConfiguration(conf *common.Configuration) (*ExpandedCon
}
// All done with this level, so return the expanded configuration
re
turn
&
ExpandedConfiguration
{
re
sult
:=
&
ExpandedConfiguration
{
Config
:
&
common
.
Configuration
{
Resources
:
resources
},
Layout
:
&
common
.
Layout
{
Resources
:
layouts
},
},
nil
}
return
result
,
nil
}
func
(
e
*
expander
)
callService
(
svcName
string
,
svcReq
*
expansion
.
ServiceRequest
)
(
*
common
.
Configuration
,
error
)
{
...
...
pkg/util/kubernetesutil.go
View file @
84dc6c9e
...
...
@@ -28,18 +28,24 @@ import (
func
ParseKubernetesObject
(
object
[]
byte
)
(
*
common
.
Resource
,
error
)
{
o
:=
&
KubernetesObject
{}
if
err
:=
yaml
.
Unmarshal
(
object
,
&
o
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot unmarshal native kubernetes object (%
#v)"
,
err
)
return
nil
,
fmt
.
Errorf
(
"cannot unmarshal native kubernetes object (%
s): %s"
,
object
,
err
)
}
// Ok, it appears to be a valid object, create a Resource out of it.
r
:=
&
common
.
Resource
{}
r
.
Name
=
getRandomName
(
o
.
Metadata
[
"name"
]
.
(
string
))
md
,
ok
:=
o
.
Metadata
[
"name"
]
.
(
string
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"cannot parse native kubernetes object (%s)"
,
object
)
}
r
.
Name
=
getRandomName
(
md
)
r
.
Type
=
o
.
Kind
r
.
Properties
=
make
(
map
[
string
]
interface
{})
if
err
:=
yaml
.
Unmarshal
(
object
,
&
r
.
Properties
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot unmarshal native kubernetes object (%
#v)"
,
err
)
return
nil
,
fmt
.
Errorf
(
"cannot unmarshal native kubernetes object (%
s): %s"
,
object
,
err
)
}
return
r
,
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