k8s_facts: fix handling of unknown resource types (#47857)

(cherry picked from commit a5c8e952e8)
This commit is contained in:
Mariusz Mazur 2018-11-06 14:43:55 +01:00 committed by Toshio Kuratomi
parent 84db20ea07
commit 642cd53857
2 changed files with 3 additions and 0 deletions

View file

@ -1,3 +1,4 @@
--- ---
bugfixes: bugfixes:
- k8s_facts now returns a resources key in all situations - k8s_facts now returns a resources key in all situations
- "k8s_facts: fix handling of unknown resource types"

View file

@ -198,6 +198,8 @@ class K8sAnsibleMixin(object):
def kubernetes_facts(self, kind, api_version, name=None, namespace=None, label_selectors=None, field_selectors=None): def kubernetes_facts(self, kind, api_version, name=None, namespace=None, label_selectors=None, field_selectors=None):
resource = self.find_resource(kind, api_version) resource = self.find_resource(kind, api_version)
if not resource:
return dict(resources=[])
try: try:
result = resource.get(name=name, result = resource.get(name=name,
namespace=namespace, namespace=namespace,