2023-10-20 12:56:59 +00:00
|
|
|
package yamlloader
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2023-12-22 13:20:45 +00:00
|
|
|
"github.com/databricks/cli/libs/dyn"
|
2023-10-20 12:56:59 +00:00
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
2023-12-22 13:20:45 +00:00
|
|
|
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 {
|
2023-10-24 11:24:43 +00:00
|
|
|
if err == io.EOF {
|
2023-12-22 13:20:45 +00:00
|
|
|
return dyn.NilValue, nil
|
2023-10-24 11:24:43 +00:00
|
|
|
}
|
2024-06-21 14:22:42 +00:00
|
|
|
return dyn.InvalidValue, err
|
2023-10-20 12:56:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return newLoader(path).load(&node)
|
|
|
|
}
|