Skip to content

Commit 0ef82fb

Browse files
committed
Refactor to use one return statement
1 parent dedada6 commit 0ef82fb

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

ocp_resources/resource.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,17 @@ def get_client(
114114
# is populated during import which comes before setting the variable in code.
115115
config_file = config_file or os.environ.get("KUBECONFIG", "~/.kube/config")
116116
proxy = proxy or os.environ.get("HTTPS_PROXY") or os.environ.get("HTTP_PROXY")
117+
client_configuration = client.Configuration()
117118

118119
if proxy:
119120
LOGGER.info(f"Trying to get client using proxy {proxy}")
120-
client_configuration = client.Configuration()
121121
client_configuration.proxy = proxy
122122

123-
return kubernetes.dynamic.DynamicClient(
124-
client=kubernetes.config.new_client_from_config(
125-
config_file=config_file,
126-
client_configuration=client_configuration,
127-
context=context or None,
128-
**kwargs,
129-
)
130-
)
131-
132123
# Ref: https://github.com/kubernetes-client/python/blob/v26.1.0/kubernetes/base/config/__init__.py
133124
LOGGER.info("Trying to get client via new_client_from_config")
134125

135126
return kubernetes.dynamic.DynamicClient(
136-
client=kubernetes.config.new_client_from_config(config_file=config_file, context=context or None, **kwargs)
127+
client=kubernetes.config.new_client_from_config(config_file=config_file, client_configuration=client_configuration, context=context or None, **kwargs)
137128
)
138129
except MaxRetryError:
139130
# Ref: https://github.com/kubernetes-client/python/blob/v26.1.0/kubernetes/base/config/incluster_config.py

0 commit comments

Comments
 (0)