This is an automated email from the ASF dual-hosted git repository.

Miretpl pushed a commit to branch chart/v1-2x-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/chart/v1-2x-test by this push:
     new d8bed613cb2 [chart/v1-2x-test] Add match schema update prek hook for 
Helm `values_schema.schema.json` file (#71680) (#71888)
d8bed613cb2 is described below

commit d8bed613cb21118a203421d7402353b0b99b96a0
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 20 21:49:07 2026 +0200

    [chart/v1-2x-test] Add match schema update prek hook for Helm 
`values_schema.schema.json` file (#71680) (#71888)
    
    * [chart/v1-2x-test] Add match schema update prek hook for Helm 
`values_schema.schema.json` file (#71680)
    
    * Add script for values_schema.schema.json match filed update
    
    * Update values_schema.schema.json file
    (cherry picked from commit da2445f05beb202671aa40344be9d4631b328d3e)
    
    Co-authored-by: Przemysław Mirowski 
<[email protected]>
    
    * Update values_schema.schema.json file
    
    ---------
    
    Co-authored-by: Przemysław Mirowski 
<[email protected]>
---
 chart/.pre-commit-config.yaml                      |   7 ++
 chart/values_schema.schema.json                    | 109 +++++++++++++++++++--
 .../update_helm_schema_schema_type_fields_match.py |  97 ++++++++++++++++++
 3 files changed, 207 insertions(+), 6 deletions(-)

diff --git a/chart/.pre-commit-config.yaml b/chart/.pre-commit-config.yaml
index 46a9959cf6b..def609b82dd 100644
--- a/chart/.pre-commit-config.yaml
+++ b/chart/.pre-commit-config.yaml
@@ -88,6 +88,13 @@ repos:
         pass_filenames: false
         files: ^values\.schema\.json$
         require_serial: true
+      - id: update-helm-values-schema-schema-file-type-field-match
+        name: Update Helm Values Schema Schema File (type field match)
+        entry: 
../scripts/ci/prek/update_helm_schema_schema_type_fields_match.py
+        language: python
+        pass_filenames: false
+        files: ^values\.schema\.json$|^values\.schema\.schema\.json$
+        require_serial: true
       - id: lint-json-schema
         name: Lint chart/values.schema.json
         entry: ../scripts/ci/prek/lint_json_schema.py
diff --git a/chart/values_schema.schema.json b/chart/values_schema.schema.json
index 320f9a41a59..eed15073568 100644
--- a/chart/values_schema.schema.json
+++ b/chart/values_schema.schema.json
@@ -22,6 +22,66 @@
             },
             "if": {
                 "oneOf": [
+                    {
+                        "properties": {
+                            "type": {
+                                "const": "array"
+                            },
+                            "items": false
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": [
+                                    "array",
+                                    "null"
+                                ]
+                            },
+                            "items": false
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": "boolean"
+                            }
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": [
+                                    "boolean",
+                                    "integer",
+                                    "number",
+                                    "string"
+                                ]
+                            }
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": [
+                                    "boolean",
+                                    "null"
+                                ]
+                            }
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": [
+                                    "boolean",
+                                    "null",
+                                    "number",
+                                    "string"
+                                ]
+                            }
+                        }
+                    },
                     {
                         "properties": {
                             "type": {
@@ -32,28 +92,41 @@
                     {
                         "properties": {
                             "type": {
-                                "const": "number"
+                                "const": [
+                                    "integer",
+                                    "null"
+                                ]
                             }
                         }
                     },
                     {
                         "properties": {
                             "type": {
-                                "const": "string"
+                                "const": [
+                                    "integer",
+                                    "null",
+                                    "string"
+                                ]
                             }
                         }
                     },
                     {
                         "properties": {
                             "type": {
-                                "const": "boolean"
+                                "const": [
+                                    "integer",
+                                    "string"
+                                ]
                             }
                         }
                     },
                     {
                         "properties": {
                             "type": {
-                                "const": "object"
+                                "const": [
+                                    "null",
+                                    "object"
+                                ]
                             },
                             "properties": false
                         }
@@ -61,9 +134,33 @@
                     {
                         "properties": {
                             "type": {
-                                "const": "array"
+                                "const": [
+                                    "null",
+                                    "string"
+                                ]
+                            }
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": "number"
+                            }
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": "object"
                             },
-                            "items": false
+                            "properties": false
+                        }
+                    },
+                    {
+                        "properties": {
+                            "type": {
+                                "const": "string"
+                            }
                         }
                     }
                 ]
diff --git a/scripts/ci/prek/update_helm_schema_schema_type_fields_match.py 
b/scripts/ci/prek/update_helm_schema_schema_type_fields_match.py
new file mode 100755
index 00000000000..f6c7ceeeb8e
--- /dev/null
+++ b/scripts/ci/prek/update_helm_schema_schema_type_fields_match.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import json
+import sys
+
+from common_prek_utils import AIRFLOW_ROOT_PATH
+
+_VALUES_SCHEMA_FILE = AIRFLOW_ROOT_PATH / "chart/values.schema.json"
+_VALUES_SCHEMA_SCHEMA_FILE = AIRFLOW_ROOT_PATH / 
"chart/values_schema.schema.json"
+
+
+if __name__ != "__main__":
+    raise SystemExit(
+        "This file is intended to be executed as an executable program. You 
cannot use it as a module."
+    )
+
+
+def _list_all_field_types(data: dict | list) -> list:
+    type_fields = []
+
+    if isinstance(data, dict):
+        if "type" in data:
+            if isinstance(data["type"], list):
+                type_fields.append(tuple(data["type"]))
+            elif not isinstance(data["type"], dict):
+                type_fields.append(data["type"])
+
+        # Skip potential `type` fields inside `default` fields as defaults are 
not
+        # part of the schema file verification process
+        temp = list((v for k, v in data.items() if k != "default"))
+    elif isinstance(data, list):
+        temp = data
+
+    for val in (val for val in temp if isinstance(val, (dict, list))):
+        type_fields.extend(_list_all_field_types(val))
+
+    return type_fields
+
+
+def _sort(data: str | tuple[str, ...]) -> str:
+    if isinstance(data, tuple):
+        return "".join(data)
+
+    return data
+
+
+def _get_one_of_for_schema(fields: list) -> list:
+    one_of: list = []
+
+    for field_type in fields:
+        one_of.append({"properties": {"type": {"const": field_type}}})
+
+        if "array" in field_type:
+            one_of[-1]["properties"]["items"] = False
+        elif "object" in field_type:
+            one_of[-1]["properties"]["properties"] = False
+
+    return one_of
+
+
+def main() -> int:
+    with open(_VALUES_SCHEMA_FILE, encoding="utf-8") as schema_file:
+        schema = json.loads(schema_file.read())
+
+    field_types = sorted(set(_list_all_field_types(schema)), key=_sort)
+
+    with open(_VALUES_SCHEMA_SCHEMA_FILE, encoding="utf-8") as schema_file:
+        schema = json.loads(schema_file.read())
+
+    schema["definitions"]["leafs"]["if"]["oneOf"] = 
_get_one_of_for_schema(field_types)
+
+    with open(_VALUES_SCHEMA_SCHEMA_FILE, "w", encoding="utf-8") as 
schema_file:
+        json.dump(schema, schema_file, indent=4)
+        schema_file.write("\n")
+
+    return 0
+
+
+sys.exit(main())

Reply via email to