From cbf6c84669bb2f5314e7b5efb1bba81cca51cda1 Mon Sep 17 00:00:00 2001 From: Tyler Gu Date: Mon, 12 Feb 2024 21:32:21 -0600 Subject: [PATCH] Fix applying property attributes Signed-off-by: Tyler Gu --- acto/checker/impl/consistency.py | 3 ++- acto/input/k8s_schemas.py | 10 +++------- data/rabbitmq-operator/custom_mapping.py | 8 ++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/acto/checker/impl/consistency.py b/acto/checker/impl/consistency.py index b9f8313d3c..3e3335063e 100644 --- a/acto/checker/impl/consistency.py +++ b/acto/checker/impl/consistency.py @@ -374,7 +374,8 @@ def check( ) if ( diff_type == "iterable_item_removed" - or corresponding_schema.patch + or corresponding_schema.attributes & PropertyAttribute.Patch + == PropertyAttribute.Patch or input_diff.path[-1] == "ACTOKEY" ): pass diff --git a/acto/input/k8s_schemas.py b/acto/input/k8s_schemas.py index fd41fedad0..b7adb81931 100644 --- a/acto/input/k8s_schemas.py +++ b/acto/input/k8s_schemas.py @@ -609,14 +609,10 @@ def expand_top_level_matched_schemas( if isinstance(crd_schema, ObjectSchema): if isinstance(k8s_schema, KubernetesObjectSchema): for key, sub_schema in crd_schema.properties.items(): - if key not in k8s_schema.properties: - raise RuntimeError( - f"Property {key} not found" - f"in k8s schema {k8s_schema.k8s_schema_name}" + if key in k8s_schema.properties: + to_explore.append( + (sub_schema, k8s_schema.properties[key]) ) - to_explore.append( - (sub_schema, k8s_schema.properties[key]) - ) elif ( isinstance(k8s_schema, KubernetesMapSchema) and crd_schema.additional_properties is not None diff --git a/data/rabbitmq-operator/custom_mapping.py b/data/rabbitmq-operator/custom_mapping.py index d82661cf06..e0d8d16f24 100644 --- a/data/rabbitmq-operator/custom_mapping.py +++ b/data/rabbitmq-operator/custom_mapping.py @@ -1,4 +1,8 @@ from acto.input.input import CustomKubernetesMapping +from acto.input.property_attribute import ( + PropertyAttribute, + tag_property_attribute, +) KUBERNETES_TYPE_MAPPING: list[CustomKubernetesMapping] = [ CustomKubernetesMapping( @@ -10,3 +14,7 @@ kubernetes_schema_name="io.k8s.api.core.v1.ServiceSpec", ), ] + +tag_property_attribute( + ["spec", "override", "statefulSet", "spec"], PropertyAttribute.Patch +)