helm/pkg/chartutil/chartfile.go
Matt Butcher 2802fcbd87 feat(chartutil): optimize for re-use
This is a refactor of the loader to use in-memory buffers instead of
trying to optimize for memory usage by delaying reads until the last
possible moment. Since charts tend to stay well below 1M in size, this
makes more sense, and is easier to work with.
2016-06-02 16:09:48 -06:00

27 lines
600 B
Go

package chartutil
import (
"io/ioutil"
"github.com/ghodss/yaml"
"github.com/kubernetes/helm/pkg/proto/hapi/chart"
)
// UnmarshalChartfile takes raw Chart.yaml data and unmarshals it.
func UnmarshalChartfile(data []byte) (*chart.Metadata, error) {
y := &chart.Metadata{}
err := yaml.Unmarshal(data, y)
if err != nil {
return nil, err
}
return y, nil
}
// LoadChartfile loads a Chart.yaml file into a *chart.Metadata.
func LoadChartfile(filename string) (*chart.Metadata, error) {
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
return UnmarshalChartfile(b)
}