From e321db9a8789d381dedf45a8c3dd5d5c80092a82 Mon Sep 17 00:00:00 2001 From: phala Date: Tue, 21 Mar 2023 10:49:26 +0100 Subject: [PATCH] Update how labels are handles in OpenshiftObjects --- testsuite/openshift/client.py | 6 +----- testsuite/openshift/objects/auth_config/__init__.py | 5 +---- testsuite/openshift/objects/auth_config/auth_policy.py | 8 +------- testsuite/openshift/objects/gateway_api/__init__.py | 5 +---- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/testsuite/openshift/client.py b/testsuite/openshift/client.py index db0176f1..1b336e31 100644 --- a/testsuite/openshift/client.py +++ b/testsuite/openshift/client.py @@ -137,14 +137,10 @@ def create_tls_secret(self, name: str, certificate: Certificate, labels: Optiona model: Dict = { "kind": "Secret", "apiVersion": "v1", - "metadata": { - "name": name, - }, + "metadata": {"name": name, "labels": labels}, "stringData": {"tls.crt": certificate.chain, "tls.key": certificate.key}, "type": "kubernetes.io/tls", } - if labels is not None: - model["metadata"]["labels"] = labels with self.context: return oc.create(model, ["--save-config=true"]) diff --git a/testsuite/openshift/objects/auth_config/__init__.py b/testsuite/openshift/objects/auth_config/__init__.py index 245e872e..de0cba5f 100644 --- a/testsuite/openshift/objects/auth_config/__init__.py +++ b/testsuite/openshift/objects/auth_config/__init__.py @@ -45,13 +45,10 @@ def create_instance( model: Dict = { "apiVersion": "authorino.kuadrant.io/v1beta1", "kind": "AuthConfig", - "metadata": {"name": name, "namespace": openshift.project}, + "metadata": {"name": name, "namespace": openshift.project, "labels": labels}, "spec": {"hosts": hostnames or route.hostnames}, } - if labels is not None: - model["metadata"]["labels"] = labels - return cls(model, context=openshift.context) @modify diff --git a/testsuite/openshift/objects/auth_config/auth_policy.py b/testsuite/openshift/objects/auth_config/auth_policy.py index 546ae58a..3a8dc2ae 100644 --- a/testsuite/openshift/objects/auth_config/auth_policy.py +++ b/testsuite/openshift/objects/auth_config/auth_policy.py @@ -39,18 +39,12 @@ def create_instance( # type: ignore model: Dict = { "apiVersion": "kuadrant.io/v1beta1", "kind": "AuthPolicy", - "metadata": { - "name": name, - "namespace": openshift.project, - }, + "metadata": {"name": name, "namespace": openshift.project, "labels": labels}, "spec": { "targetRef": route.reference, }, } - if labels is not None: - model["metadata"]["labels"] = labels - return cls(model, context=openshift.context, route=route) def add_host(self, hostname): diff --git a/testsuite/openshift/objects/gateway_api/__init__.py b/testsuite/openshift/objects/gateway_api/__init__.py index 754e3502..de2b777d 100644 --- a/testsuite/openshift/objects/gateway_api/__init__.py +++ b/testsuite/openshift/objects/gateway_api/__init__.py @@ -49,7 +49,7 @@ def create_instance( model = { "apiVersion": "gateway.networking.k8s.io/v1alpha2", "kind": "HTTPRoute", - "metadata": {"name": name, "namespace": openshift.project}, + "metadata": {"name": name, "namespace": openshift.project, "labels": labels}, "spec": { "parentRefs": [parent.reference], "hostnames": [hostname], @@ -57,9 +57,6 @@ def create_instance( }, } - if labels is not None: - model["metadata"]["labels"] = labels # type: ignore - return cls(model, context=openshift.context) @property