Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise ConfigException on invalid named-arguments to load_incluster_config #2204

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion kubernetes/base/config/incluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ def _read_token_file(self):
) + self._token_refresh_period


def load_incluster_config(client_configuration=None, try_refresh_token=True):
def load_incluster_config(client_configuration=None, try_refresh_token=True, **kwds):
"""
Use the service account kubernetes gives to pods to connect to kubernetes
cluster. It's intended for clients that expect to be running inside a pod
running on kubernetes. It will raise an exception if called from a process
not running in a kubernetes environment."""
for val in kds.values():
addyess marked this conversation as resolved.
Show resolved Hide resolved
if val is not None:
raise ConfigException(f"Unimplemented named-argument {val} for incluster config.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is ConfigException better than TypeError ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its only slightly better because the client code only has to catch one exception -- ConfigException

Secondarily, this will allow callers to: load_config

to call with a keyword arg like context=None and load_incluster_config won't bark with the TypeError, but if there is a context=<val> that's non-none, we'll get a meaningful exceptions from load_incluster_config

InClusterConfigLoader(
token_filename=SERVICE_TOKEN_FILENAME,
cert_filename=SERVICE_CERT_FILENAME,
Expand Down