mirror of
https://github.com/helm/helm.git
synced 2026-04-15 21:59:50 -04:00
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.
27 lines
600 B
Go
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)
|
|
}
|