Python linting

This commit is contained in:
T. Andrew Manning 2024-12-17 08:58:29 -06:00
parent 47d581a6ac
commit ad07deae24

View file

@ -6,7 +6,6 @@ import signal
import sys import sys
import threading import threading
from unicodedata import name
from kubernetes import client, config, watch from kubernetes import client, config, watch
from kubernetes.client.rest import ApiException from kubernetes.client.rest import ApiException
@ -39,10 +38,10 @@ def create_certificate(crds, namespace, secretname, routes):
Create a certificate request for certmanager based on the IngressRoute Create a certificate request for certmanager based on the IngressRoute
""" """
try: try:
secret = crds.get_namespaced_custom_object(CERT_GROUP, CERT_VERSION, namespace, CERT_PLURAL, secretname) # secret = crds.get_namespaced_custom_object(CERT_GROUP, CERT_VERSION, namespace, CERT_PLURAL, secretname)
logging.info(f"{secretname} : certificate request already exists.") logging.info(f"{secretname} : certificate request already exists.")
return return
except ApiException as e: except ApiException:
pass pass
for route in routes: for route in routes:
@ -88,7 +87,7 @@ def watch_crd(group, version, plural):
""" """
Watch Traefik IngressRoute CRD and create/delete certificates based on them Watch Traefik IngressRoute CRD and create/delete certificates based on them
""" """
#config.load_kube_config() # config.load_kube_config()
config.load_incluster_config() config.load_incluster_config()
crds = client.CustomObjectsApi() crds = client.CustomObjectsApi()
resource_version = "" resource_version = ""
@ -117,7 +116,7 @@ def watch_crd(group, version, plural):
# if no secretName is set, add one to the IngressRoute # if no secretName is set, add one to the IngressRoute
if not secretname and PATCH_SECRETNAME: if not secretname and PATCH_SECRETNAME:
logging.info(f"{namespace}/{name} : no secretName found in IngressRoute, patch to add one") logging.info(f"{namespace}/{name} : no secretName found in IngressRoute, patch to add one")
patch = { "spec": { "tls": { "secretName": name }}} patch = {"spec": {"tls": {"secretName": name}}}
crds.patch_namespaced_custom_object(group, version, namespace, plural, name, patch) crds.patch_namespaced_custom_object(group, version, namespace, plural, name, patch)
secretname = name secretname = name
if secretname: if secretname: