ParseYAML reads the bytes from a file, parses the bytes into a mapping structure, and returns it.
(source []byte)
| 60 | // ParseYAML reads the bytes from a file, parses the bytes into a mapping |
| 61 | // structure, and returns it. |
| 62 | func ParseYAML(source []byte) (map[string]any, error) { |
| 63 | var cfg any |
| 64 | if err := yaml.Unmarshal(source, &cfg); err != nil { |
| 65 | return nil, err |
| 66 | } |
| 67 | _, ok := cfg.(map[string]any) |
| 68 | if !ok { |
| 69 | return nil, errors.New("top-level object must be a mapping") |
| 70 | } |
| 71 | converted, err := convertToStringKeysRecursive(cfg, "") |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | return converted.(map[string]any), nil |
| 76 | } |
| 77 | |
| 78 | // Load reads a ConfigDetails and returns a fully loaded configuration |
| 79 | func Load(configDetails types.ConfigDetails, opt ...func(*Options)) (*types.Config, error) { |
searching dependent graphs…