This is an automated email from the ASF dual-hosted git repository.
Miretpl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 3931d6ab6dc Fix Helm chart parameter examples that fail the chart's
own schema (#72698)
3931d6ab6dc is described below
commit 3931d6ab6dc16c4d3ef0d93a12706fae373e2c5a
Author: PoAn Yang <[email protected]>
AuthorDate: Sun Sep 13 05:57:50 2026 +0900
Fix Helm chart parameter examples that fail the chart's own schema (#72698)
Signed-off-by: PoAn Yang <[email protected]>
---
.../helm_tests/airflow_aux/test_chart_quality.py | 32 ++++++++++++-
chart/values.schema.json | 54 ++++++++++++----------
2 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/chart/tests/helm_tests/airflow_aux/test_chart_quality.py
b/chart/tests/helm_tests/airflow_aux/test_chart_quality.py
index 81c52322053..cae3eef8281 100644
--- a/chart/tests/helm_tests/airflow_aux/test_chart_quality.py
+++ b/chart/tests/helm_tests/airflow_aux/test_chart_quality.py
@@ -18,11 +18,28 @@ from __future__ import annotations
import json
from pathlib import Path
+from typing import Any
+import pytest
import yaml
-from jsonschema import validate
+from jsonschema import validate, validators
+from jsonschema.exceptions import best_match
CHART_DIR = Path(__file__).parents[4] / "chart"
+VALUES_SCHEMA = json.loads((CHART_DIR / "values.schema.json").read_text())
+
+
+def _iter_schemas_with_examples(schema: dict[str, Any], path: str = ""):
+ if schema.get("examples"):
+ yield path, schema
+ for name, child in (schema.get("properties") or {}).items():
+ yield from _iter_schemas_with_examples(child, f"{path}.{name}" if path
else name)
+ for key, suffix in (("items", "[]"), ("additionalProperties", ".*")):
+ if isinstance(schema.get(key), dict):
+ yield from _iter_schemas_with_examples(schema[key],
f"{path}{suffix}")
+
+
+SCHEMAS_WITH_EXAMPLES = dict(_iter_schemas_with_examples(VALUES_SCHEMA))
class TestChartQuality:
@@ -39,3 +56,16 @@ class TestChartQuality:
# shouldn't raise
validate(instance=values, schema=schema)
+
+ @pytest.mark.parametrize("path", SCHEMAS_WITH_EXAMPLES)
+ def test_schema_examples_validate_against_their_own_schema(self, path):
+ """Examples are rendered verbatim into the parameters reference, so
they must be valid values."""
+ schema = SCHEMAS_WITH_EXAMPLES[path]
+ validator = validators.validator_for(VALUES_SCHEMA)(
+ {**schema, "definitions": VALUES_SCHEMA["definitions"]}
+ )
+ for example in schema["examples"]:
+ # chart/docs/conf.py renders each example of an array parameter as
a single list element
+ instance = [example] if schema.get("type") == "array" else example
+ error = best_match(validator.iter_errors(instance))
+ assert error is None, f"{path}: {error.message}"
diff --git a/chart/values.schema.json b/chart/values.schema.json
index f6f13b94e98..57685ff8bc6 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -2747,26 +2747,34 @@
},
"examples": [
{
- "name": "data-volume-1",
- "storageClassName": "storage-class-1",
- "accessModes": [
- "ReadWriteOnce"
- ],
- "resources": {
- "requests": {
- "storage": "10Gi"
+ "metadata": {
+ "name": "data-volume-1"
+ },
+ "spec": {
+ "storageClassName": "storage-class-1",
+ "accessModes": [
+ "ReadWriteOnce"
+ ],
+ "resources": {
+ "requests": {
+ "storage": "10Gi"
+ }
}
}
},
{
- "name": "data-volume-2",
- "storageClassName": "storage-class-2",
- "accessModes": [
- "ReadWriteOnce"
- ],
- "resources": {
- "requests": {
- "storage": "20Gi"
+ "metadata": {
+ "name": "data-volume-2"
+ },
+ "spec": {
+ "storageClassName": "storage-class-2",
+ "accessModes": [
+ "ReadWriteOnce"
+ ],
+ "resources": {
+ "requests": {
+ "storage": "20Gi"
+ }
}
}
}
@@ -6460,12 +6468,10 @@
"type": "array",
"default": [],
"examples": [
- [
- {
- "name": "FORWARDED_ALLOW_IPS",
- "value": "*"
- }
- ]
+ {
+ "name": "FORWARDED_ALLOW_IPS",
+ "value": "*"
+ }
],
"items": {
"type": "object",
@@ -8757,7 +8763,7 @@
"user": "...",
"pass": "...",
"host": "...",
- "port": "..."
+ "port": 9200
}
]
}
@@ -8820,7 +8826,7 @@
"user": "...",
"pass": "...",
"host": "...",
- "port": "..."
+ "port": 9200
}
]
}