Skip to content

Commit

Permalink
Do not load user kube config if path specified (ansible#49952)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding authored and gundalow committed Jan 11, 2019
1 parent 64bacb0 commit be5b788
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- openshift inventory plugin - do not default create client if auth parameters were given.
2 changes: 1 addition & 1 deletion lib/ansible/plugins/inventory/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def setup(self, config_data, cache, cache_key):
self.fetch_objects(connections)

def fetch_objects(self, connections):
client = self.get_api_client()

if connections:
if not isinstance(connections, list):
Expand All @@ -184,6 +183,7 @@ def fetch_objects(self, connections):
self.get_pods_for_namespace(client, name, namespace)
self.get_services_for_namespace(client, name, namespace)
else:
client = self.get_api_client()
name = self.get_default_host_name(client.configuration.host)
namespaces = self.get_available_namespaces(client)
for namespace in namespaces:
Expand Down
5 changes: 4 additions & 1 deletion lib/ansible/plugins/inventory/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ class InventoryModule(K8sInventoryModule):

def fetch_objects(self, connections):
super(InventoryModule, self).fetch_objects(connections)
client = self.get_api_client()

if connections:
if not isinstance(connections, list):
raise K8sInventoryException("Expecting connections to be a list.")

for connection in connections:
client = self.get_api_client(**connection)
name = connection.get('name', self.get_default_host_name(client.configuration.host))
Expand All @@ -136,6 +138,7 @@ def fetch_objects(self, connections):
for namespace in namespaces:
self.get_routes_for_namespace(client, name, namespace)
else:
client = self.get_api_client()
name = self.get_default_host_name(client.configuration.host)
namespaces = self.get_available_namespaces(client)
for namespace in namespaces:
Expand Down

0 comments on commit be5b788

Please sign in to comment.