diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index a091f373..ebbee63e 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -376,6 +376,46 @@ def getStorageClasses(dynClient: DynamicClient) -> list: return storageClasses +def getClusterIssuers(dynClient: DynamicClient) -> list: + """ + 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.