Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

helm_plugin and helm_plugin_info: new module #154

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions molecule/default/roles/helm/tasks/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
- from_repository
- from_url

- name: Test helm plugin
include_tasks: tests_helm_plugin.yml

- name: Clean helm install
file:
path: "{{ item }}"
Expand Down
84 changes: 84 additions & 0 deletions molecule/default/roles/helm/tasks/tests_helm_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
- name: Install env plugin in check mode
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: present
plugin_path: https://github.com/adamreese/helm-env
register: check_install_env
check_mode: true

- assert:
that:
- check_install_env.changed

- name: Install env plugin
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: present
plugin_path: https://github.com/adamreese/helm-env
register: install_env

- assert:
that:
- install_env.changed

- name: Gather info about all plugin
helm_plugin_info:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
register: plugin_info

- assert:
that:
- plugin_info.plugin_list is defined

- name: Install env plugin again
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: present
plugin_path: https://github.com/adamreese/helm-env
register: install_env

- assert:
that:
- not install_env.changed

- name: Uninstall env plugin in check mode
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: absent
plugin_name: env
register: check_uninstall_env
check_mode: true

- assert:
that:
- check_uninstall_env.changed

- name: Uninstall env plugin
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: absent
plugin_name: env
register: uninstall_env

- assert:
that:
- uninstall_env.changed

- name: Uninstall env plugin again
helm_plugin:
binary_path: "{{ helm_binary }}"
namespace: "{{ helm_namespace }}"
state: absent
plugin_name: env
register: uninstall_env

- assert:
that:
- not uninstall_env.changed
34 changes: 34 additions & 0 deletions plugins/doc_fragments/helm_common_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2020, Ansible Project
# Copyright: (c) 2020, Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Options for common Helm modules

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


class ModuleDocFragment(object):

DOCUMENTATION = r'''
options:
binary_path:
description:
- The path of a helm binary to use.
required: false
type: path
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
aliases: [ kube_context ]
kubeconfig:
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_path]
'''
19 changes: 2 additions & 17 deletions plugins/modules/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
- Install, upgrade, delete packages with the Helm package manager.

options:
binary_path:
description:
- The path of a helm binary to use.
required: false
type: path
chart_ref:
description:
- chart_reference on chart repository.
Expand Down Expand Up @@ -95,18 +90,6 @@
- Helm option to force reinstall, ignore on new install.
default: False
type: bool
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
aliases: [ context ]
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:
description:
- Remove the release from the store and make its name free for later use.
Expand All @@ -132,6 +115,8 @@
type: bool
default: False
version_added: "0.11.1"
extends_documentation_fragment:
- community.kubernetes.helm_common_options
'''

EXAMPLES = r'''
Expand Down
21 changes: 2 additions & 19 deletions plugins/modules/helm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
- Get information (values, states, ...) from Helm package deployed inside the cluster.

options:
binary_path:
description:
- The path of a helm binary to use.
required: false
type: path
release_name:
description:
- Release name to manage.
Expand All @@ -43,20 +38,8 @@
required: true
type: str
aliases: [ namespace ]

#Helm options
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
aliases: [ context ]
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 ]
extends_documentation_fragment:
- community.kubernetes.helm_common_options
'''

EXAMPLES = r'''
Expand Down
Loading