Skip to content

Commit

Permalink
helm: Add support for K8S_AUTH_CONTEXT, K8S_AUTH_KUBECONFIG env (ansi…
Browse files Browse the repository at this point in the history
…ble-collections#141)

Added support for K8S_AUTH_CONTEXT, K8S_AUTH_KUBECONFIG env
  • Loading branch information
Akasurde authored Jul 2, 2020
1 parent 7056800 commit ef6722d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/140_kubeconfig_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- helm - add support for K8S_AUTH_KUBECONFIG and K8S_AUTH_CONTEXT environment variable (https://github.com/ansible-collections/community.kubernetes/issues/140).
- helm_info - add support for K8S_AUTH_KUBECONFIG and K8S_AUTH_CONTEXT environment variable (https://github.com/ansible-collections/community.kubernetes/issues/140).
8 changes: 5 additions & 3 deletions plugins/modules/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@
kube_context:
description:
- Helm option to specify which kubeconfig context to use.
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_CONTEXT) will be used instead.
type: str
kubeconfig_path:
description:
- Helm option to specify kubeconfig path to use.
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_KUBECONFIG) will be used instead.
type: path
aliases: [ kubeconfig ]
purge:
Expand Down Expand Up @@ -245,7 +247,7 @@
IMP_YAML_ERR = traceback.format_exc()
IMP_YAML = False

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback

module = None

Expand Down Expand Up @@ -395,8 +397,8 @@ def main():
# Helm options
disable_hook=dict(type='bool', default=False),
force=dict(type='bool', default=False),
kube_context=dict(type='str'),
kubeconfig_path=dict(type='path', aliases=['kubeconfig']),
kube_context=dict(type='str', fallback=(env_fallback, ['K8S_AUTH_CONTEXT'])),
kubeconfig_path=dict(type='path', aliases=['kubeconfig'], fallback=(env_fallback, ['K8S_AUTH_KUBECONFIG'])),
purge=dict(type='bool', default=True),
wait=dict(type='bool', default=False),
wait_timeout=dict(type='str'),
Expand Down
8 changes: 5 additions & 3 deletions plugins/modules/helm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
kube_context:
description:
- Helm option to specify which kubeconfig context to use.
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_CONTEXT) will be used instead.
type: str
kubeconfig_path:
description:
- Helm option to specify kubeconfig path to use.
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_KUBECONFIG) will be used instead.
type: path
aliases: [ kubeconfig ]
'''
Expand Down Expand Up @@ -112,7 +114,7 @@
IMP_YAML_ERR = traceback.format_exc()
IMP_YAML = False

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback

module = None

Expand Down Expand Up @@ -177,8 +179,8 @@ def main():
release_namespace=dict(type='str', required=True, aliases=['namespace']),

# Helm options
kube_context=dict(type='str'),
kubeconfig_path=dict(type='path', aliases=['kubeconfig']),
kube_context=dict(type='str', fallback=(env_fallback, ['K8S_AUTH_CONTEXT'])),
kubeconfig_path=dict(type='path', aliases=['kubeconfig'], fallback=(env_fallback, ['K8S_AUTH_KUBECONFIG'])),
),
supports_check_mode=True,
)
Expand Down

0 comments on commit ef6722d

Please sign in to comment.