Commit 49795ad9 authored by jackgr's avatar jackgr

Add chart content loading

parent 131ddcbc
...@@ -377,12 +377,21 @@ func (c *Chart) loadDirectory(dir string) ([]*ChartMember, error) { ...@@ -377,12 +377,21 @@ func (c *Chart) loadDirectory(dir string) ([]*ChartMember, error) {
members := []*ChartMember{} members := []*ChartMember{}
for _, file := range files { for _, file := range files {
filename := filepath.Join(dir, file.Name()) filename := filepath.Join(dir, file.Name())
member, err := c.loadMember(filename) if !file.IsDir() {
addition, err := c.loadMember(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
members = append(members, member) members = append(members, addition)
} else {
additions, err := c.loadDirectory(filename)
if err != nil {
return nil, err
}
members = append(members, additions...)
}
} }
return members, nil return members, nil
...@@ -416,3 +425,22 @@ func (c *Chart) loadMember(filename string) (*ChartMember, error) { ...@@ -416,3 +425,22 @@ func (c *Chart) loadMember(filename string) (*ChartMember, error) {
return result, nil return result, nil
} }
type ChartContent struct {
Chartfile *Chartfile `json:"chartfile"`
Members []*ChartMember `json:"templates"`
}
func (c *Chart) LoadContent() (*ChartContent, error) {
ms, err := c.loadDirectory(c.Dir())
if err != nil {
return nil, err
}
cc := &ChartContent{
Chartfile: c.Chartfile(),
Members: ms,
}
return cc, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment