airshipctl/pkg/util/configreader.go

18 lines
327 B
Go

package util
import (
"io/ioutil"
"sigs.k8s.io/yaml"
)
// ReadYAMLFile reads YAML-formatted configuration file and
// de-serializes it to a given object
func ReadYAMLFile(filePath string, cfg interface{}) error {
data, err := ioutil.ReadFile(filePath)
if err != nil {
return err
}
return yaml.Unmarshal(data, cfg)
}