|
|
@ -14,6 +14,8 @@ import (
|
|
|
|
"github.com/kubernetes/deployment-manager/log"
|
|
|
|
"github.com/kubernetes/deployment-manager/log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ChartfileName string = "Chart.yaml"
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
preTemplates string = "templates/"
|
|
|
|
preTemplates string = "templates/"
|
|
|
|
preHooks string = "hooks/"
|
|
|
|
preHooks string = "hooks/"
|
|
|
@ -42,11 +44,13 @@ type Chart interface {
|
|
|
|
// Dir returns a directory where the chart can be accessed.
|
|
|
|
// Dir returns a directory where the chart can be accessed.
|
|
|
|
Dir() string
|
|
|
|
Dir() string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Close cleans up a chart.
|
|
|
|
Close() error
|
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type dirChart struct {
|
|
|
|
type dirChart struct {
|
|
|
|
chartfile *Chartfile
|
|
|
|
chartfile *Chartfile
|
|
|
|
|
|
|
|
dir string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *dirChart) Chartfile() *Chartfile {
|
|
|
|
func (d *dirChart) Chartfile() *Chartfile {
|
|
|
@ -99,6 +103,7 @@ func LoadDir(chart string) (Chart, error) {
|
|
|
|
|
|
|
|
|
|
|
|
c := &dirChart{
|
|
|
|
c := &dirChart{
|
|
|
|
chartfile: cf,
|
|
|
|
chartfile: cf,
|
|
|
|
|
|
|
|
dir: chart,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return c, nil
|
|
|
|
return c, nil
|
|
|
@ -128,10 +133,20 @@ func Load(archive string) (Chart, error) {
|
|
|
|
defer unzipped.Close()
|
|
|
|
defer unzipped.Close()
|
|
|
|
|
|
|
|
|
|
|
|
untarred := tar.NewReader(unzipped)
|
|
|
|
untarred := tar.NewReader(unzipped)
|
|
|
|
return loadTar(untarred)
|
|
|
|
c, err := loadTar(untarred)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return c, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cf, err := LoadChartfile(filepath.Join(c.tmpDir, ChartfileName))
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return c, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.chartfile = cf
|
|
|
|
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func loadTar(r *tar.Reader) (Chart, error) {
|
|
|
|
func loadTar(r *tar.Reader) (*tarChart, error) {
|
|
|
|
td, err := ioutil.TempDir("", "chart-")
|
|
|
|
td, err := ioutil.TempDir("", "chart-")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|