Change the return key of k8s_facts (#44446)

`items` is a *terrible* return key for ansible as Jinja
will often think it refers to the `items()` function.

Even though you can typically work around this with
`results['items']`, sometimes even that doesn't work:

```
- name: Resources should exist
  assert:
    that: item.status.phase == 'Active'
  loop: "{{ k8s_namespaces['items'] }}"
```

```
fatal: [testhost]: FAILED! => {"msg": "Invalid data passed to 'loop', it
requires a list, got this instead: <built-in method items of dict object
at 0x109dc9c58>. Hint: If you passed a list/dict of just one element,
try adding wantlist=True to your lookup invocation or use q/query
instead of lookup."}
```

Change it now while we still can.
This commit is contained in:
Will Thames 2018-08-29 21:04:04 +10:00 committed by John R Barker
parent 1ef225601a
commit b35ac8080f
2 changed files with 3 additions and 3 deletions

View file

@ -214,9 +214,9 @@ class K8sAnsibleMixin(object):
return dict(items=[])
if 'items' in result:
return result
return dict(resources=result['items'])
else:
return dict(items=[result])
return dict(resources=[result])
def remove_aliases(self):
"""

View file

@ -101,7 +101,7 @@ EXAMPLES = '''
'''
RETURN = '''
items:
resources:
description:
- The object(s) that exists
returned: success