Skip to content

Commit f84958d

Browse files
committed
feat: refactor deletePattern variable
Change variable to string from int (magic number) If acm chart gets deleteSpokeChildApps, it will set, deletePattern to deleteChildApps and pass it to its app of apps (clustergroup chart)
1 parent 95b7a26 commit f84958d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

templates/_helpers.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,15 @@ Default always defined valueFiles to be included when pushing the cluster wide a
5656
value: {{ $.Values.global.privateRepo | quote }}
5757
- name: global.experimentalCapabilities
5858
value: {{ $.Values.global.experimentalCapabilities }}
59+
{{/*
60+
if this chart gets DeleteSpokeChildApps, it will set deletePattern to DeleteChildApps to remove the child apps from spokes
61+
*/}}
5962
- name: global.deletePattern
60-
value: {{ $.Values.global.deletePattern | quote }}
63+
{{- if eq $.Values.global.deletePattern "DeleteSpokeChildApps" }}
64+
value: DeleteChildApps
65+
{{- else }}
66+
value: {{ $.Values.global.deletePattern }}
67+
{{- end }}
6168
{{- end }} {{- /*acm.app.policies.helmparameters */}}
6269

6370
{{- define "acm.app.clusterSelector" -}}

templates/policies/application-policies.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# TODO: Also create a GitOpsCluster.apps.open-cluster-management.io
22
{{- range .Values.clusterGroup.managedClusterGroups }}
33
{{- $group := . }}
4-
{{- if ne ($.Values.global.deletePattern | default "0" | int) 0 }}
4+
{{- if ($.Values.global.deletePattern | eq "DeleteSpoke" ) }}
5+
{{- else }}
56
apiVersion: policy.open-cluster-management.io/v1
67
kind: Policy
78
metadata:
@@ -131,7 +132,7 @@ spec:
131132
namespace: {{ $.Values.global.pattern }}-{{ .name }}
132133
syncPolicy:
133134
automated:
134-
{{- if eq ($.Values.global.deletePattern | default "0" | int) 1 }}
135+
{{- if ($.Values.global.deletePattern | ne "none" ) }}
135136
prune: true
136137
{{- else }}
137138
prune: false

0 commit comments

Comments
 (0)