LoadValues loads values from a reader. The reader is expected to contain one or more YAML documents, the values of which are merged. And the values can be either a chart's default values or user-supplied values.
(data io.Reader)
| 210 | // The reader is expected to contain one or more YAML documents, the values of which are merged. |
| 211 | // And the values can be either a chart's default values or user-supplied values. |
| 212 | func LoadValues(data io.Reader) (map[string]any, error) { |
| 213 | values := map[string]any{} |
| 214 | reader := utilyaml.NewYAMLReader(bufio.NewReader(data)) |
| 215 | for { |
| 216 | currentMap := map[string]any{} |
| 217 | raw, err := reader.Read() |
| 218 | if err != nil { |
| 219 | if errors.Is(err, io.EOF) { |
| 220 | break |
| 221 | } |
| 222 | return nil, fmt.Errorf("error reading yaml document: %w", err) |
| 223 | } |
| 224 | if err := yaml.Unmarshal(raw, ¤tMap); err != nil { |
| 225 | return nil, fmt.Errorf("cannot unmarshal yaml document: %w", err) |
| 226 | } |
| 227 | values = MergeMaps(values, currentMap) |
| 228 | } |
| 229 | return values, nil |
| 230 | } |
| 231 | |
| 232 | // MergeMaps merges two maps. If a key exists in both maps, the value from b will be used. |
| 233 | // If the value is a map, the maps will be merged recursively. |
searching dependent graphs…