Fix client regression from turbo mode refactor (#79)

* Fix client regression from turbo mode refactor

The turbo mode refactoring introduced a regression where the kubernetes
client can fail to find the kubeconfig. This happens because
get_api_client is called twice and the second time it is called without
the module being passed as an argument. Without this, the configuration
will use defaults. This will be a problem if the user has specified a
location for the kubeconfig that's different from default, for example.

* Add tests
This commit is contained in:
Mike Graves
2021-04-22 15:13:38 -04:00
committed by GitHub
parent 48c5170018
commit 8b2d39d6d2
3 changed files with 34 additions and 2 deletions

View File

@@ -508,7 +508,7 @@ class K8sAnsibleMixin(object):
changed = False
results = []
try:
self.client = get_api_client()
self.client = get_api_client(self.module)
# Hopefully the kubernetes client will provide its own exception class one day
except (urllib3.exceptions.RequestError) as e:
self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e))