package repo import ( "io/ioutil" "gopkg.in/yaml.v2" ) // RepoFile represents the .repositories file in $HELM_HOME type RepoFile struct { Repositories map[string]string } // LoadRepositoriesFile takes a file at the given path and returns a RepoFile object func LoadRepositoriesFile(path string) (*RepoFile, error) { b, err := ioutil.ReadFile(path) if err != nil { return nil, err } var r RepoFile err = yaml.Unmarshal(b, &r) if err != nil { return nil, err } return &r, nil } // UnmarshalYAML unmarshals the repo file func (rf *RepoFile) UnmarshalYAML(unmarshal func(interface{}) error) error { var repos map[string]string if err := unmarshal(&repos); err != nil { if _, ok := err.(*yaml.TypeError); !ok { return err } } rf.Repositories = repos return nil }