databricks-cli/libs/dyn/yamlloader/yaml.go

23 lines
370 B
Go
Raw Permalink Normal View History

2023-10-20 12:56:59 +00:00
package yamlloader
import (
"io"
"github.com/databricks/cli/libs/dyn"
2023-10-20 12:56:59 +00:00
"gopkg.in/yaml.v3"
)
func LoadYAML(path string, r io.Reader) (dyn.Value, error) {
2023-10-20 12:56:59 +00:00
var node yaml.Node
dec := yaml.NewDecoder(r)
err := dec.Decode(&node)
if err != nil {
if err == io.EOF {
return dyn.NilValue, nil
}
return dyn.NilValue, err
2023-10-20 12:56:59 +00:00
}
return newLoader(path).load(&node)
}