From 7199c14a8d12c9aa623a1df2de6bef6c9f6d800a Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Fri, 25 Dec 2020 12:11:42 -0500 Subject: [PATCH 01/12] Change KUBE_CONFIG_DEFAULT_LOCATION to use pathlib.Path.home instead of hard-coded "~". This is a more "Pythonic" way of setting that value. --- config/kube_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/kube_config.py b/config/kube_config.py index 0ed5a71cf..5c862287b 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -19,6 +19,7 @@ import datetime import json import logging import os +import pathlib import platform import subprocess import tempfile @@ -45,7 +46,7 @@ except ImportError: pass EXPIRY_SKEW_PREVENTION_DELAY = datetime.timedelta(minutes=5) -KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', '~/.kube/config') +KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', f'{pathlib.Path.home()}/.kube/config') ENV_KUBECONFIG_PATH_SEPARATOR = ';' if platform.system() == 'Windows' else ':' _temp_files = {} From 0c662bb33dfb49236ca4c68b81d426d8948da224 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Fri, 25 Dec 2020 12:22:38 -0500 Subject: [PATCH 02/12] Adding load_config wrapper method to have a more generic way of initializing the client config --- config/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/config/__init__.py b/config/__init__.py index b57bf185a..d9d7f4bbd 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -12,7 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os from .config_exception import ConfigException from .incluster_config import load_incluster_config from .kube_config import (list_kube_config_contexts, load_kube_config, - load_kube_config_from_dict, new_client_from_config) + load_kube_config_from_dict, new_client_from_config, KUBE_CONFIG_DEFAULT_LOCATION) + + +def load_config(**kwargs): + """ + Wrapper function to load the kube_config. + It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists + If neither exists- it will fall back to load_incluster_config and inform the user accordingly. + """ + if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): + load_kube_config(**kwargs) + else: + print(f"kube_config_path not provided and default location ({KUBE_CONFIG_DEFAULT_LOCATION}) does not exist. " + "Using inCluster Config. This might not work.") + load_incluster_config(**kwargs) From 10db259908b025cfdcbba28c455de9bac54e16aa Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Fri, 25 Dec 2020 12:59:27 -0500 Subject: [PATCH 03/12] Document kwargs param --- config/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/__init__.py b/config/__init__.py index d9d7f4bbd..1ff2dec25 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -24,6 +24,9 @@ def load_config(**kwargs): Wrapper function to load the kube_config. It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists If neither exists- it will fall back to load_incluster_config and inform the user accordingly. + + :param kwargs: A combination of all possible kwargs that can be passed to either load_kube_config or + load_incluster_config functions. """ if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): load_kube_config(**kwargs) From 2c9ddf94b6614c9f16a234de0ce69e01270466c6 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Mon, 4 Jan 2021 23:58:25 -0500 Subject: [PATCH 04/12] Revert switch to pathlib, to maintain Python2 support --- config/kube_config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/kube_config.py b/config/kube_config.py index 5c862287b..0ed5a71cf 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -19,7 +19,6 @@ import datetime import json import logging import os -import pathlib import platform import subprocess import tempfile @@ -46,7 +45,7 @@ except ImportError: pass EXPIRY_SKEW_PREVENTION_DELAY = datetime.timedelta(minutes=5) -KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', f'{pathlib.Path.home()}/.kube/config') +KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', '~/.kube/config') ENV_KUBECONFIG_PATH_SEPARATOR = ';' if platform.system() == 'Windows' else ':' _temp_files = {} From 9bce8696ffb10e30757e93e72d5c4970d5144c16 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sun, 21 Mar 2021 23:01:35 -0400 Subject: [PATCH 05/12] Switching print statement to use legacy .format() method, in order to maintain backwards-compatibility with pre-3.6 Python versions --- config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 1ff2dec25..204819eb8 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -31,6 +31,6 @@ def load_config(**kwargs): if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): load_kube_config(**kwargs) else: - print(f"kube_config_path not provided and default location ({KUBE_CONFIG_DEFAULT_LOCATION}) does not exist. " - "Using inCluster Config. This might not work.") + print("kube_config_path not provided and default location ({0}) does not exist. " + "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) load_incluster_config(**kwargs) From 0395a107185cef66592dfd26dbb8118179d272c4 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sun, 21 Mar 2021 23:27:47 -0400 Subject: [PATCH 06/12] Run black linter to make update-pycodestyle happy --- config/__init__.py | 21 +++++++++++---- watch/watch.py | 64 ++++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 204819eb8..2ab141cd5 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -15,8 +15,13 @@ import os from .config_exception import ConfigException from .incluster_config import load_incluster_config -from .kube_config import (list_kube_config_contexts, load_kube_config, - load_kube_config_from_dict, new_client_from_config, KUBE_CONFIG_DEFAULT_LOCATION) +from .kube_config import ( + list_kube_config_contexts, + load_kube_config, + load_kube_config_from_dict, + new_client_from_config, + KUBE_CONFIG_DEFAULT_LOCATION, +) def load_config(**kwargs): @@ -28,9 +33,15 @@ def load_config(**kwargs): :param kwargs: A combination of all possible kwargs that can be passed to either load_kube_config or load_incluster_config functions. """ - if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): + if "kube_config_path" in kwargs.keys() or os.path.exists( + KUBE_CONFIG_DEFAULT_LOCATION + ): load_kube_config(**kwargs) else: - print("kube_config_path not provided and default location ({0}) does not exist. " - "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) + print( + "kube_config_path not provided and default location ({0}) does not exist. " + "Using inCluster Config. This might not work.".format( + KUBE_CONFIG_DEFAULT_LOCATION + ) + ) load_incluster_config(**kwargs) diff --git a/watch/watch.py b/watch/watch.py index b432778e7..4047be0f7 100644 --- a/watch/watch.py +++ b/watch/watch.py @@ -32,14 +32,15 @@ TYPE_LIST_SUFFIX = "List" PY2 = sys.version_info[0] == 2 if PY2: import httplib + HTTP_STATUS_GONE = httplib.GONE else: import http + HTTP_STATUS_GONE = http.HTTPStatus.GONE class SimpleNamespace: - def __init__(self, **kwargs): self.__dict__.update(kwargs) @@ -47,7 +48,7 @@ class SimpleNamespace: def _find_return_type(func): for line in pydoc.getdoc(func).splitlines(): if line.startswith(PYDOC_RETURN_LABEL): - return line[len(PYDOC_RETURN_LABEL):].strip() + return line[len(PYDOC_RETURN_LABEL) :].strip() return "" @@ -55,7 +56,7 @@ def iter_resp_lines(resp): prev = "" for seg in resp.read_chunked(decode_content=False): if isinstance(seg, bytes): - seg = seg.decode('utf8') + seg = seg.decode("utf8") seg = prev + seg lines = seg.split("\n") if not seg.endswith("\n"): @@ -69,7 +70,6 @@ def iter_resp_lines(resp): class Watch(object): - def __init__(self, return_type=None): self._raw_return_type = return_type self._stop = False @@ -84,29 +84,31 @@ class Watch(object): return self._raw_return_type return_type = _find_return_type(func) if return_type.endswith(TYPE_LIST_SUFFIX): - return return_type[:-len(TYPE_LIST_SUFFIX)] + return return_type[: -len(TYPE_LIST_SUFFIX)] return return_type def get_watch_argument_name(self, func): if PYDOC_FOLLOW_PARAM in pydoc.getdoc(func): - return 'follow' + return "follow" else: - return 'watch' + return "watch" def unmarshal_event(self, data, return_type): js = json.loads(data) - js['raw_object'] = js['object'] - if return_type and js['type'] != 'ERROR': - obj = SimpleNamespace(data=json.dumps(js['raw_object'])) - js['object'] = self._api_client.deserialize(obj, return_type) - if hasattr(js['object'], 'metadata'): - self.resource_version = js['object'].metadata.resource_version + js["raw_object"] = js["object"] + if return_type and js["type"] != "ERROR": + obj = SimpleNamespace(data=json.dumps(js["raw_object"])) + js["object"] = self._api_client.deserialize(obj, return_type) + if hasattr(js["object"], "metadata"): + self.resource_version = js["object"].metadata.resource_version # For custom objects that we don't have model defined, json # deserialization results in dictionary - elif (isinstance(js['object'], dict) and 'metadata' in js['object'] - and 'resourceVersion' in js['object']['metadata']): - self.resource_version = js['object']['metadata'][ - 'resourceVersion'] + elif ( + isinstance(js["object"], dict) + and "metadata" in js["object"] + and "resourceVersion" in js["object"]["metadata"] + ): + self.resource_version = js["object"]["metadata"]["resourceVersion"] return js def stream(self, func, *args, **kwargs): @@ -147,13 +149,13 @@ class Watch(object): return_type = self.get_return_type(func) watch_arg = self.get_watch_argument_name(func) kwargs[watch_arg] = True - kwargs['_preload_content'] = False - if 'resource_version' in kwargs: - self.resource_version = kwargs['resource_version'] + kwargs["_preload_content"] = False + if "resource_version" in kwargs: + self.resource_version = kwargs["resource_version"] # Do not attempt retries if user specifies a timeout. # We want to ensure we are returning within that timeout. - disable_retries = ('timeout_seconds' in kwargs) + disable_retries = "timeout_seconds" in kwargs retry_after_410 = False while True: resp = func(*args, **kwargs) @@ -163,20 +165,22 @@ class Watch(object): # return raw string when we are streaming log if watch_arg == "watch": event = self.unmarshal_event(line, return_type) - if isinstance(event, dict) \ - and event['type'] == 'ERROR': - obj = event['raw_object'] + if isinstance(event, dict) and event["type"] == "ERROR": + obj = event["raw_object"] # Current request expired, let's retry, (if enabled) # but only if we have not already retried. - if not disable_retries and not retry_after_410 and \ - obj['code'] == HTTP_STATUS_GONE: + if ( + not disable_retries + and not retry_after_410 + and obj["code"] == HTTP_STATUS_GONE + ): retry_after_410 = True break else: - reason = "%s: %s" % ( - obj['reason'], obj['message']) + reason = "%s: %s" % (obj["reason"], obj["message"]) raise client.rest.ApiException( - status=obj['code'], reason=reason) + status=obj["code"], reason=reason + ) else: retry_after_410 = False yield event @@ -188,7 +192,7 @@ class Watch(object): resp.close() resp.release_conn() if self.resource_version is not None: - kwargs['resource_version'] = self.resource_version + kwargs["resource_version"] = self.resource_version else: self._stop = True From 34b8304d5fe0b95df8b9968f766cf9e8598e778a Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sun, 21 Mar 2021 23:38:48 -0400 Subject: [PATCH 07/12] autopep8 --- watch/watch.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/watch/watch.py b/watch/watch.py index 4047be0f7..7a143f7e9 100644 --- a/watch/watch.py +++ b/watch/watch.py @@ -48,7 +48,7 @@ class SimpleNamespace: def _find_return_type(func): for line in pydoc.getdoc(func).splitlines(): if line.startswith(PYDOC_RETURN_LABEL): - return line[len(PYDOC_RETURN_LABEL) :].strip() + return line[len(PYDOC_RETURN_LABEL):].strip() return "" @@ -177,7 +177,8 @@ class Watch(object): retry_after_410 = True break else: - reason = "%s: %s" % (obj["reason"], obj["message"]) + reason = "%s: %s" % ( + obj["reason"], obj["message"]) raise client.rest.ApiException( status=obj["code"], reason=reason ) From 0a5b04feead64f73ae042665251e3aef5e35f84e Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sun, 21 Mar 2021 23:44:32 -0400 Subject: [PATCH 08/12] Revert black and only try autopep8 this time --- config/__init__.py | 21 ++++------------ watch/watch.py | 61 +++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 49 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 2ab141cd5..204819eb8 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -15,13 +15,8 @@ import os from .config_exception import ConfigException from .incluster_config import load_incluster_config -from .kube_config import ( - list_kube_config_contexts, - load_kube_config, - load_kube_config_from_dict, - new_client_from_config, - KUBE_CONFIG_DEFAULT_LOCATION, -) +from .kube_config import (list_kube_config_contexts, load_kube_config, + load_kube_config_from_dict, new_client_from_config, KUBE_CONFIG_DEFAULT_LOCATION) def load_config(**kwargs): @@ -33,15 +28,9 @@ def load_config(**kwargs): :param kwargs: A combination of all possible kwargs that can be passed to either load_kube_config or load_incluster_config functions. """ - if "kube_config_path" in kwargs.keys() or os.path.exists( - KUBE_CONFIG_DEFAULT_LOCATION - ): + if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): load_kube_config(**kwargs) else: - print( - "kube_config_path not provided and default location ({0}) does not exist. " - "Using inCluster Config. This might not work.".format( - KUBE_CONFIG_DEFAULT_LOCATION - ) - ) + print("kube_config_path not provided and default location ({0}) does not exist. " + "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) load_incluster_config(**kwargs) diff --git a/watch/watch.py b/watch/watch.py index 7a143f7e9..b432778e7 100644 --- a/watch/watch.py +++ b/watch/watch.py @@ -32,15 +32,14 @@ TYPE_LIST_SUFFIX = "List" PY2 = sys.version_info[0] == 2 if PY2: import httplib - HTTP_STATUS_GONE = httplib.GONE else: import http - HTTP_STATUS_GONE = http.HTTPStatus.GONE class SimpleNamespace: + def __init__(self, **kwargs): self.__dict__.update(kwargs) @@ -56,7 +55,7 @@ def iter_resp_lines(resp): prev = "" for seg in resp.read_chunked(decode_content=False): if isinstance(seg, bytes): - seg = seg.decode("utf8") + seg = seg.decode('utf8') seg = prev + seg lines = seg.split("\n") if not seg.endswith("\n"): @@ -70,6 +69,7 @@ def iter_resp_lines(resp): class Watch(object): + def __init__(self, return_type=None): self._raw_return_type = return_type self._stop = False @@ -84,31 +84,29 @@ class Watch(object): return self._raw_return_type return_type = _find_return_type(func) if return_type.endswith(TYPE_LIST_SUFFIX): - return return_type[: -len(TYPE_LIST_SUFFIX)] + return return_type[:-len(TYPE_LIST_SUFFIX)] return return_type def get_watch_argument_name(self, func): if PYDOC_FOLLOW_PARAM in pydoc.getdoc(func): - return "follow" + return 'follow' else: - return "watch" + return 'watch' def unmarshal_event(self, data, return_type): js = json.loads(data) - js["raw_object"] = js["object"] - if return_type and js["type"] != "ERROR": - obj = SimpleNamespace(data=json.dumps(js["raw_object"])) - js["object"] = self._api_client.deserialize(obj, return_type) - if hasattr(js["object"], "metadata"): - self.resource_version = js["object"].metadata.resource_version + js['raw_object'] = js['object'] + if return_type and js['type'] != 'ERROR': + obj = SimpleNamespace(data=json.dumps(js['raw_object'])) + js['object'] = self._api_client.deserialize(obj, return_type) + if hasattr(js['object'], 'metadata'): + self.resource_version = js['object'].metadata.resource_version # For custom objects that we don't have model defined, json # deserialization results in dictionary - elif ( - isinstance(js["object"], dict) - and "metadata" in js["object"] - and "resourceVersion" in js["object"]["metadata"] - ): - self.resource_version = js["object"]["metadata"]["resourceVersion"] + elif (isinstance(js['object'], dict) and 'metadata' in js['object'] + and 'resourceVersion' in js['object']['metadata']): + self.resource_version = js['object']['metadata'][ + 'resourceVersion'] return js def stream(self, func, *args, **kwargs): @@ -149,13 +147,13 @@ class Watch(object): return_type = self.get_return_type(func) watch_arg = self.get_watch_argument_name(func) kwargs[watch_arg] = True - kwargs["_preload_content"] = False - if "resource_version" in kwargs: - self.resource_version = kwargs["resource_version"] + kwargs['_preload_content'] = False + if 'resource_version' in kwargs: + self.resource_version = kwargs['resource_version'] # Do not attempt retries if user specifies a timeout. # We want to ensure we are returning within that timeout. - disable_retries = "timeout_seconds" in kwargs + disable_retries = ('timeout_seconds' in kwargs) retry_after_410 = False while True: resp = func(*args, **kwargs) @@ -165,23 +163,20 @@ class Watch(object): # return raw string when we are streaming log if watch_arg == "watch": event = self.unmarshal_event(line, return_type) - if isinstance(event, dict) and event["type"] == "ERROR": - obj = event["raw_object"] + if isinstance(event, dict) \ + and event['type'] == 'ERROR': + obj = event['raw_object'] # Current request expired, let's retry, (if enabled) # but only if we have not already retried. - if ( - not disable_retries - and not retry_after_410 - and obj["code"] == HTTP_STATUS_GONE - ): + if not disable_retries and not retry_after_410 and \ + obj['code'] == HTTP_STATUS_GONE: retry_after_410 = True break else: reason = "%s: %s" % ( - obj["reason"], obj["message"]) + obj['reason'], obj['message']) raise client.rest.ApiException( - status=obj["code"], reason=reason - ) + status=obj['code'], reason=reason) else: retry_after_410 = False yield event @@ -193,7 +188,7 @@ class Watch(object): resp.close() resp.release_conn() if self.resource_version is not None: - kwargs["resource_version"] = self.resource_version + kwargs['resource_version'] = self.resource_version else: self._stop = True From cf2f312fd06debceee9a06afe2eefccbd2649f1e Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sun, 21 Mar 2021 23:59:43 -0400 Subject: [PATCH 09/12] Applied autopep8 properly this time. This should work --- config/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 204819eb8..c7c68777a 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -15,8 +15,12 @@ import os from .config_exception import ConfigException from .incluster_config import load_incluster_config -from .kube_config import (list_kube_config_contexts, load_kube_config, - load_kube_config_from_dict, new_client_from_config, KUBE_CONFIG_DEFAULT_LOCATION) +from .kube_config import ( + list_kube_config_contexts, + load_kube_config, + load_kube_config_from_dict, + new_client_from_config, + KUBE_CONFIG_DEFAULT_LOCATION) def load_config(**kwargs): @@ -28,9 +32,11 @@ def load_config(**kwargs): :param kwargs: A combination of all possible kwargs that can be passed to either load_kube_config or load_incluster_config functions. """ - if "kube_config_path" in kwargs.keys() or os.path.exists(KUBE_CONFIG_DEFAULT_LOCATION): + if "kube_config_path" in kwargs.keys() or os.path.exists( + KUBE_CONFIG_DEFAULT_LOCATION): load_kube_config(**kwargs) else: - print("kube_config_path not provided and default location ({0}) does not exist. " - "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) + print( + "kube_config_path not provided and default location ({0}) does not exist. " + "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) load_incluster_config(**kwargs) From b5aa2dd3718949a066cf1f01927ef4432f2e4dcc Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Mon, 22 Mar 2021 00:16:52 -0400 Subject: [PATCH 10/12] Address remarks from pycodestyle --- config/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index c7c68777a..607adc72b 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -26,10 +26,13 @@ from .kube_config import ( def load_config(**kwargs): """ Wrapper function to load the kube_config. - It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists - If neither exists- it will fall back to load_incluster_config and inform the user accordingly. + It will initially try to load_kube_config from provided path, + then check if the KUBE_CONFIG_DEFAULT_LOCATION exists + If neither exists- it will fall back to load_incluster_config + and inform the user accordingly. - :param kwargs: A combination of all possible kwargs that can be passed to either load_kube_config or + :param kwargs: A combination of all possible kwargs that + can be passed to either load_kube_config or load_incluster_config functions. """ if "kube_config_path" in kwargs.keys() or os.path.exists( @@ -37,6 +40,8 @@ def load_config(**kwargs): load_kube_config(**kwargs) else: print( - "kube_config_path not provided and default location ({0}) does not exist. " - "Using inCluster Config. This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) + "kube_config_path not provided and " + "default location ({0}) does not exist. " + "Using inCluster Config. " + "This might not work.".format(KUBE_CONFIG_DEFAULT_LOCATION)) load_incluster_config(**kwargs) From 698299af9d3229d02624c4e6bb87e076bdcea000 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Mon, 22 Mar 2021 00:22:04 -0400 Subject: [PATCH 11/12] isort --- config/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config/__init__.py b/config/__init__.py index 607adc72b..41702b965 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -13,14 +13,12 @@ # limitations under the License. import os + from .config_exception import ConfigException from .incluster_config import load_incluster_config -from .kube_config import ( - list_kube_config_contexts, - load_kube_config, - load_kube_config_from_dict, - new_client_from_config, - KUBE_CONFIG_DEFAULT_LOCATION) +from .kube_config import (KUBE_CONFIG_DEFAULT_LOCATION, + list_kube_config_contexts, load_kube_config, + load_kube_config_from_dict, new_client_from_config) def load_config(**kwargs): From 6d1c8d3713057e87d973d853b36373c06901d092 Mon Sep 17 00:00:00 2001 From: Moshe Shitrit Date: Sat, 19 Jun 2021 17:42:37 +0300 Subject: [PATCH 12/12] Apply suggestion --- config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/__init__.py b/config/__init__.py index 41702b965..76297f817 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -26,7 +26,7 @@ def load_config(**kwargs): Wrapper function to load the kube_config. It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists - If neither exists- it will fall back to load_incluster_config + If neither exists, it will fall back to load_incluster_config and inform the user accordingly. :param kwargs: A combination of all possible kwargs that