Fix helm ignoring given context (#387)

Fixes: #385
This commit is contained in:
Mike Graves
2021-03-15 00:34:06 -04:00
committed by GitHub
parent af41efdf46
commit c4182ad84f
3 changed files with 22 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- helm - fix helm ignoring the kubeconfig context when passed through the ``context`` param or the ``K8S_AUTH_CONTEXT`` environment variable (https://github.com/ansible-collections/community.kubernetes/issues/385).

View File

@@ -348,6 +348,24 @@
that:
result.stat.exists
- name: Release using non-existent context
helm:
binary_path: "{{ helm_binary }}"
name: test
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
context: does-not-exist
ignore_errors: yes
register: result
- name: Assert that release fails with non-existent context
assert:
that:
- result is failed
- "'context \"does-not-exist\" does not exist' in result.stderr"
always:
- name: Clean up temp dir
file:

View File

@@ -28,8 +28,8 @@ def prepare_helm_environ_update(module):
environ_update = {}
file_to_cleam_up = None
kubeconfig_path = module.params.get('kubeconfig')
if module.params.get('kube_context') is not None:
environ_update["HELM_KUBECONTEXT"] = module.params.get('kube_context')
if module.params.get('context') is not None:
environ_update["HELM_KUBECONTEXT"] = module.params.get('context')
if module.params.get('release_namespace'):
environ_update["HELM_NAMESPACE"] = module.params.get('release_namespace')
if module.params.get("api_key"):