forked from ansible-collections/community.kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional support for helm diff (ansible-collections#355)
There are some cases where the existing module has difficulty determining if an upgrade would result in changes. This can particularly be a problem when changes are made to a local chart. This adds optional support for helm diff. If the plugin is present it will be used. Otherwise, the default implementation will be used and a warning will be issued. One caveat: helm diff does not currently support using a repo url, so the default implementation will be used in this case, as well. Closes: ansible-collections#248
- Loading branch information
Showing
15 changed files
with
299 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- helm - add optional support for helm diff (https://github.com/ansible-collections/community.kubernetes/issues/248). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
molecule/default/roles/helm/files/appversionless-chart-v2/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v2 | ||
name: appversionless-chart | ||
description: A chart used in molecule tests | ||
type: application | ||
version: 0.2.0 |
7 changes: 7 additions & 0 deletions
7
molecule/default/roles/helm/files/appversionless-chart-v2/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-chart-configmap | ||
data: | ||
myValue: {{ default "test" .Values.myValue }} | ||
myOtherValue: {{ default "foo" .Values.myOtherValue }} |
6 changes: 6 additions & 0 deletions
6
molecule/default/roles/helm/files/appversionless-chart/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-chart-configmap | ||
data: | ||
myValue: {{ default "test" .Values.myValue }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: test-chart | ||
description: A chart used in molecule tests | ||
type: application | ||
version: 0.2.0 | ||
appVersion: "default" |
7 changes: 7 additions & 0 deletions
7
molecule/default/roles/helm/files/test-chart-v2/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-chart-configmap | ||
data: | ||
myValue: {{ default "test" .Values.myValue }} | ||
myOtherValue: {{ default "foo" .Values.myOtherValue }} |
6 changes: 6 additions & 0 deletions
6
molecule/default/roles/helm/files/test-chart/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-chart-configmap | ||
data: | ||
myValue: {{ default "test" .Values.myValue }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
--- | ||
- name: Test helm diff functionality | ||
vars: | ||
test_chart_ref: "/tmp/test-chart" | ||
|
||
block: | ||
- name: Install helm diff | ||
helm_plugin: | ||
namespace: "{{ helm_namespace }}" | ||
state: present | ||
plugin_path: https://github.com/databus23/helm-diff | ||
|
||
- name: Copy test chart | ||
copy: | ||
src: "test-chart/" | ||
dest: "{{ test_chart_ref }}" | ||
|
||
- name: Install local chart | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
create_namespace: yes | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is changed | ||
|
||
- name: Modify local chart | ||
blockinfile: | ||
create: yes | ||
path: "{{ test_chart_ref }}/templates/anothermap.yaml" | ||
block: !unsafe | | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-chart-another-configmap | ||
data: | ||
foo: {{ .Values.foo | default "bar" }} | ||
- name: Upgrade local chart with modifications | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is changed | ||
|
||
- name: Upgrade modified local chart idempotency check | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is not changed | ||
|
||
- name: Modify values | ||
blockinfile: | ||
create: yes | ||
path: "{{ test_chart_ref }}/values.yml" | ||
block: | | ||
--- | ||
foo: baz | ||
- name: Upgrade with values file | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
values_files: | ||
- "{{ test_chart_ref }}/values.yml" | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is changed | ||
|
||
- name: Upgrade with values file idempotency check | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
values_files: | ||
- "{{ test_chart_ref }}/values.yml" | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is not changed | ||
|
||
- name: Upgrade with values | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
values: | ||
foo: gaz | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is changed | ||
|
||
- name: Upgrade with values idempotency check | ||
helm: | ||
binary_path: "{{ helm_binary }}" | ||
name: test-chart | ||
namespace: "{{ helm_namespace }}" | ||
chart_ref: "{{ test_chart_ref }}" | ||
values: | ||
foo: gaz | ||
register: install | ||
|
||
- assert: | ||
that: | ||
- install is not changed | ||
|
||
always: | ||
- name: Remove chart directory | ||
file: | ||
path: "{{ test_chart_ref }}" | ||
state: absent | ||
ignore_errors: yes | ||
|
||
- name: Uninstall helm diff | ||
helm_plugin: | ||
namespace: "{{ helm_namespace }}" | ||
state: absent | ||
plugin_name: diff | ||
ignore_errors: yes | ||
|
||
- name: Remove helm namespace | ||
k8s: | ||
api_version: v1 | ||
kind: Namespace | ||
name: "{{ helm_namespace }}" | ||
state: absent | ||
wait: yes | ||
wait_timeout: 180 | ||
ignore_errors: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.