From 0c58bfd68002483332a79c4152fd8c23e85cc4e8 Mon Sep 17 00:00:00 2001 From: mudakavip Date: Thu, 19 Sep 2024 16:22:00 -0500 Subject: [PATCH 1/2] fix: Moving default token filename outisde of class --- .../neutron_understack/argo/workflows.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/neutron-understack/neutron_understack/argo/workflows.py b/python/neutron-understack/neutron_understack/argo/workflows.py index bd0ab367..7877aca8 100644 --- a/python/neutron-understack/neutron_understack/argo/workflows.py +++ b/python/neutron-understack/neutron_understack/argo/workflows.py @@ -6,9 +6,10 @@ urllib3.disable_warnings() -class ArgoClient: - DEFAULT_TOKEN_FILENAME = "/run/secrets/kubernetes.io/serviceaccount/token" +DEFAULT_TOKEN_FILENAME = "/run/secrets/kubernetes.io/serviceaccount/token" + +class ArgoClient: def __init__( self, token: str = None, @@ -16,15 +17,15 @@ def __init__( api_url="https://argo-server.argo.svc.cluster.local:2746", logger=None, ): + if token is None: + with open(DEFAULT_TOKEN_FILENAME) as token_file: + token = token_file.read() self.token = token self.namespace = namespace self.api_url = api_url self.headers = {"Authorization": f"Bearer {self.token}"} self.logger = logger - if token is None: - with open(DEFAULT_TOKEN_FILENAME) as token_file: - token = token_file.read() def submit( self, From f45103e4266afac736b1d127a84f49ddce092c32 Mon Sep 17 00:00:00 2001 From: mudakavip Date: Thu, 19 Sep 2024 16:25:25 -0500 Subject: [PATCH 2/2] based on PR feedback --- python/neutron-understack/neutron_understack/argo/workflows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/neutron-understack/neutron_understack/argo/workflows.py b/python/neutron-understack/neutron_understack/argo/workflows.py index 7877aca8..4e6b97d7 100644 --- a/python/neutron-understack/neutron_understack/argo/workflows.py +++ b/python/neutron-understack/neutron_understack/argo/workflows.py @@ -12,7 +12,7 @@ class ArgoClient: def __init__( self, - token: str = None, + token: str | None = None, namespace="default", api_url="https://argo-server.argo.svc.cluster.local:2746", logger=None,