Ensure that k8s_facts always returns resources key (#46733)
Fix bug returning `items` key if NotFound exception is hit
This commit is contained in:
parent
8a31d26e31
commit
b772485d97
2 changed files with 15 additions and 2 deletions
|
@ -189,7 +189,7 @@ class K8sAnsibleMixin(object):
|
||||||
label_selector=','.join(label_selectors),
|
label_selector=','.join(label_selectors),
|
||||||
field_selector=','.join(field_selectors)).to_dict()
|
field_selector=','.join(field_selectors)).to_dict()
|
||||||
except openshift.dynamic.exceptions.NotFoundError:
|
except openshift.dynamic.exceptions.NotFoundError:
|
||||||
return dict(items=[])
|
return dict(resources=[])
|
||||||
|
|
||||||
if 'items' in result:
|
if 'items' in result:
|
||||||
return dict(resources=result['items'])
|
return dict(resources=result['items'])
|
||||||
|
|
|
@ -15,6 +15,19 @@
|
||||||
debug:
|
debug:
|
||||||
var: output
|
var: output
|
||||||
|
|
||||||
|
- name: k8s_facts works with empty resources
|
||||||
|
k8s_facts:
|
||||||
|
kind: Deployment
|
||||||
|
namespace: testing
|
||||||
|
api_version: extensions/v1beta1
|
||||||
|
register: k8s_facts
|
||||||
|
|
||||||
|
- name: assert that k8s_facts is in correct format
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'resources' in k8s_facts"
|
||||||
|
- not k8s_facts.resources
|
||||||
|
|
||||||
- name: Create a service
|
- name: Create a service
|
||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
|
@ -85,7 +98,7 @@
|
||||||
k8s:
|
k8s:
|
||||||
state: present
|
state: present
|
||||||
inline: &deployment
|
inline: &deployment
|
||||||
apiVersion: apps/v1beta1
|
apiVersion: extensions/v1beta1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: elastic
|
name: elastic
|
||||||
|
|
Loading…
Reference in a new issue