in internal/policygen/load.go [54:82]
func loadConfig(path string) (*config, error) {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("read config %q: %v", path, err)
}
// Convert yaml to json so hcl decoder can parse it.
if filepath.Ext(path) == ".yaml" {
b, err = yaml.YAMLToJSON(b)
if err != nil {
return nil, err
}
// hclsimple.Decode doesn't actually use the path for anything other
// than its extension, so just pass in any file name ending with json so
// the library knows to treat these bytes as json and not yaml.
path = "file.json"
}
c := new(config)
if err := hclsimple.Decode(path, b, nil, c); err != nil {
return nil, err
}
if err := c.init(); err != nil {
return nil, err
}
return c, nil
}