You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
helm/pkg/repo/repo.go

41 lines
792 B

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
}