(valuesPath string, overrides map[string]any, skipSchemaValidation bool)
| 54 | } |
| 55 | |
| 56 | func validateValuesFile(valuesPath string, overrides map[string]any, skipSchemaValidation bool) error { |
| 57 | values, err := common.ReadValuesFile(valuesPath) |
| 58 | if err != nil { |
| 59 | return fmt.Errorf("unable to parse YAML: %w", err) |
| 60 | } |
| 61 | |
| 62 | // Helm 3.0.0 carried over the values linting from Helm 2.x, which only tests the top |
| 63 | // level values against the top-level expectations. Subchart values are not linted. |
| 64 | // We could change that. For now, though, we retain that strategy, and thus can |
| 65 | // coalesce tables (like reuse-values does) instead of doing the full chart |
| 66 | // CoalesceValues |
| 67 | coalescedValues := util.CoalesceTables(make(map[string]any, len(overrides)), overrides) |
| 68 | coalescedValues = util.CoalesceTables(coalescedValues, values) |
| 69 | |
| 70 | ext := filepath.Ext(valuesPath) |
| 71 | schemaPath := valuesPath[:len(valuesPath)-len(ext)] + ".schema.json" |
| 72 | schema, err := os.ReadFile(schemaPath) |
| 73 | if len(schema) == 0 { |
| 74 | return nil |
| 75 | } |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | if !skipSchemaValidation { |
| 81 | return util.ValidateAgainstSingleSchema(coalescedValues, schema) |
| 82 | } |
| 83 | |
| 84 | return nil |
| 85 | } |
searching dependent graphs…