From c219c6e27eac649d8f26302d29ae9636b7b9a5b9 Mon Sep 17 00:00:00 2001 From: terc1997 <64480693+terc1997@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:18:01 -0300 Subject: [PATCH 1/5] [patch] add function to fetch cluster issuers --- src/mas/devops/ocp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index a091f373..2957974f 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -376,6 +376,12 @@ def getStorageClasses(dynClient: DynamicClient) -> list: return storageClasses +def getClusterIssuers(dynClient: DynamicClient) -> list: + clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io", kind="ClusterIssuer") + clusterIssuers = clusterIssuerAPI.get().items + return clusterIssuers + + def isSNO(dynClient: DynamicClient) -> bool: """ Check if the cluster is a Single Node OpenShift (SNO) deployment. From 9ede49f71c931a7bf120de37d44019297d5b2e30 Mon Sep 17 00:00:00 2001 From: terc1997 <64480693+terc1997@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:23:39 -0300 Subject: [PATCH 2/5] [patch] add function to get a single cluster issuer by name --- src/mas/devops/ocp.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index 2957974f..ebbee63e 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -377,11 +377,45 @@ def getStorageClasses(dynClient: DynamicClient) -> list: def getClusterIssuers(dynClient: DynamicClient) -> list: - clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io", kind="ClusterIssuer") + """ + Get all ClusterIssuers in the cluster. + + Parameters: + dynClient (DynamicClient): OpenShift Dynamic Client + + Returns: + list: List of ClusterIssuers resources + + Raises: + NotFoundError: If ClusterIssuers cannot be retrieved + """ + clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io/v1", kind="ClusterIssuer") clusterIssuers = clusterIssuerAPI.get().items return clusterIssuers +def getClusterIssuer(dynClient: DynamicClient, name: str) -> str: + """ + Get a specific ClusterIssuer by name. + + Parameters: + dynClient (DynamicClient): OpenShift Dynamic Client + name (str): The name of the ClusterIssuer to retrieve + + Returns: + ClusterIssuer: The ClusterIssuer resource, or None if not found + + Raises: + NotFoundError: If the ClusterIssuer does not exist (caught and returns None) + """ + try: + clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io/v1", kind="ClusterIssuer") + clusterIssuer = clusterIssuerAPI.get(name=name) + return clusterIssuer + except NotFoundError: + return None + + def isSNO(dynClient: DynamicClient) -> bool: """ Check if the cluster is a Single Node OpenShift (SNO) deployment. From 7395e3c7998d3bdad3690ad78d319807ab2ffca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A1rsis=20Augusto?= <64480693+terc1997@users.noreply.github.com> Date: Tue, 10 Feb 2026 15:41:28 -0300 Subject: [PATCH 3/5] [patch] fix formatting --- src/mas/devops/ocp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index bfe47536..22c1d997 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -414,6 +414,8 @@ def getClusterIssuer(dynClient: DynamicClient, name: str) -> str: return clusterIssuer except NotFoundError: return None + + def getStorageClassVolumeBindingMode(dynClient: DynamicClient, storageClassName: str) -> str: """ Get the volumeBindingMode for a storage class. From 55f9fed5c48174a2f36890e3160ee1b5c2cf2513 Mon Sep 17 00:00:00 2001 From: terc1997 <64480693+terc1997@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:28:15 -0300 Subject: [PATCH 4/5] [patch] update typehint --- src/mas/devops/ocp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index 04024450..01aa4e22 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -19,6 +19,7 @@ from kubernetes import client from kubernetes.stream import stream from kubernetes.stream.ws_client import ERROR_CHANNEL +from kubernetes.dynamic.resource import ResourceInstance import yaml @@ -394,7 +395,7 @@ def getClusterIssuers(dynClient: DynamicClient) -> list: return clusterIssuers -def getClusterIssuer(dynClient: DynamicClient, name: str) -> str: +def getClusterIssuer(dynClient: DynamicClient, name: str) -> ResourceInstance: """ Get a specific ClusterIssuer by name. From 87e97ed949fa4fc99c15dcc157cd0310d06b25e6 Mon Sep 17 00:00:00 2001 From: terc1997 <64480693+terc1997@users.noreply.github.com> Date: Mon, 25 May 2026 16:20:47 -0300 Subject: [PATCH 5/5] [patch] remove redundant Raises sections from docstrings --- src/mas/devops/ocp.py | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index 1fc28024..b846a29e 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -86,9 +86,6 @@ def getClusterVersion(dynClient: DynamicClient) -> str: Returns: str: The cluster version string (e.g., "4.12.0"), or None if not found - - Raises: - NotFoundError: If the ClusterVersion resource cannot be retrieved """ clusterVersionAPI = dynClient.resources.get(api_version="config.openshift.io/v1", kind="ClusterVersion") @@ -132,8 +129,6 @@ def getNamespace(dynClient: DynamicClient, namespace: str) -> dict: Returns: dict: The namespace resource as a dictionary, or an empty dict if not found - Raises: - NotFoundError: If the namespace does not exist """ namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace") @@ -143,7 +138,6 @@ def getNamespace(dynClient: DynamicClient, namespace: str) -> dict: return ns except NotFoundError: logger.debug(f"Namespace {namespace} does not exist") - return {} @@ -161,9 +155,6 @@ def createNamespace(dynClient: DynamicClient, namespace: str, kyvernoLabel: str Returns: bool: Always returns True - - Raises: - NotFoundError: If the namespace resource cannot be accessed """ namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace") try: @@ -205,9 +196,6 @@ def deleteNamespace(dynClient: DynamicClient, namespace: str) -> bool: Returns: bool: Always returns True - - Raises: - NotFoundError: If the namespace does not exist (caught and logged) """ namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace") try: @@ -230,9 +218,6 @@ def waitForCRD(dynClient: DynamicClient, crdName: str) -> bool: Returns: bool: True if the CRD becomes established, False if timeout is reached - - Raises: - NotFoundError: If the CRD is not found (caught and retried) """ crdAPI = dynClient.resources.get(api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition") maxRetries = 100 @@ -275,9 +260,6 @@ def waitForDeployment(dynClient: DynamicClient, namespace: str, deploymentName: Returns: bool: True if the deployment becomes ready, False if timeout is reached - - Raises: - NotFoundError: If the deployment is not found (caught and retried) """ deploymentAPI = dynClient.resources.get(api_version="apps/v1", kind="Deployment") maxRetries = 100 @@ -310,9 +292,6 @@ def getConsoleURL(dynClient: DynamicClient) -> str: Returns: str: The HTTPS URL of the OpenShift console (e.g., "https://console-openshift-console.apps.cluster.example.com") - - Raises: - NotFoundError: If the console route is not found """ routesAPI = dynClient.resources.get(api_version="route.openshift.io/v1", kind="Route") consoleRoute = routesAPI.get(name="console", namespace="openshift-console") @@ -328,9 +307,6 @@ def getNodes(dynClient: DynamicClient) -> dict: Returns: list: List of node resources as dictionaries - - Raises: - NotFoundError: If nodes cannot be retrieved """ nodesAPI = dynClient.resources.get(api_version="v1", kind="Node") nodes = nodesAPI.get().to_dict()['items'] @@ -347,9 +323,6 @@ def getStorageClass(dynClient: DynamicClient, name: str) -> dict | None: Returns: StorageClass: The StorageClass resource, or None if not found - - Raises: - NotFoundError: If the StorageClass does not exist (caught and returns None) """ try: storageClassAPI = dynClient.resources.get(api_version="storage.k8s.io/v1", kind="StorageClass") @@ -368,9 +341,6 @@ def getStorageClasses(dynClient: DynamicClient) -> list: Returns: list: List of StorageClass resources - - Raises: - NotFoundError: If StorageClasses cannot be retrieved """ storageClassAPI = dynClient.resources.get(api_version="storage.k8s.io/v1", kind="StorageClass") storageClasses = storageClassAPI.get().items @@ -385,17 +355,14 @@ def getClusterIssuers(dynClient: DynamicClient) -> list: dynClient (DynamicClient): OpenShift Dynamic Client Returns: - list: List of ClusterIssuers resources - - Raises: - NotFoundError: If ClusterIssuers cannot be retrieved + list: List of ClusterIssuers resources or an empty list if no cluster issuers """ clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io/v1", kind="ClusterIssuer") clusterIssuers = clusterIssuerAPI.get().items return clusterIssuers -def getClusterIssuer(dynClient: DynamicClient, name: str) -> ResourceInstance: +def getClusterIssuer(dynClient: DynamicClient, name: str) -> ResourceInstance | None: """ Get a specific ClusterIssuer by name. @@ -405,9 +372,6 @@ def getClusterIssuer(dynClient: DynamicClient, name: str) -> ResourceInstance: Returns: ClusterIssuer: The ClusterIssuer resource, or None if not found - - Raises: - NotFoundError: If the ClusterIssuer does not exist (caught and returns None) """ try: clusterIssuerAPI = dynClient.resources.get(api_version="cert-manager.io/v1", kind="ClusterIssuer")