helm: return correct information in check mode (#281)

Fixes: #280

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde
2020-10-23 01:52:17 +05:30
committed by GitHub
parent aad4696f20
commit 77e48d0c97
3 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- helm - return values in check mode when release is not present (https://github.com/ansible-collections/community.kubernetes/issues/280).

View File

@@ -27,6 +27,24 @@
- install_fail is failed
- "'Error: create: failed to create: namespaces \"' + helm_namespace + '\" not found' in install_fail.stderr"
- name: "Install {{ chart_test }} from {{ source }} in check mode"
helm:
binary_path: "{{ helm_binary }}"
name: test
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
register: install_check_mode
check_mode: true
- name: "Assert that {{ chart_test }} chart is installed from {{ source }} in check mode"
assert:
that:
- install_check_mode is changed
- install_check_mode.status is defined
- install_check_mode.status.values is defined
- name: "Install {{ chart_test }} from {{ source }}"
helm:
binary_path: "{{ helm_binary }}"

View File

@@ -537,10 +537,15 @@ def main():
changed = True
if module.check_mode:
check_status = {'values': {
"current": release_status['values'],
"declared": release_values
}}
check_status = {
'values': {
"current": {},
"declared": {},
}
}
if release_status:
check_status['values']['current'] = release_status['values']
check_status['values']['declared'] = release_status
module.exit_json(
changed=changed,