Add chart content loading

pull/408/head
jackgr 9 years ago
parent 131ddcbce6
commit 49795ad9fd

@ -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() {
if err != nil { addition, err := c.loadMember(filename)
return nil, err if err != nil {
} return nil, err
}
members = append(members, addition)
} else {
additions, err := c.loadDirectory(filename)
if err != nil {
return nil, err
}
members = append(members, member) members = append(members, additions...)
}
} }
return members, nil return members, nil
@ -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
}

Loading…
Cancel
Save