diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 4d8a119..555802c 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -32,6 +32,9 @@ Default always defined top-level variables for helm charts value: {{ $.Values.global.privateRepo | quote }} - name: global.experimentalCapabilities value: {{ $.Values.global.experimentalCapabilities | default "" }} +- name: global.deletePattern + value: {{ $.Values.global.deletePattern }} + {{- end }} {{/* clustergroup.globalvaluesparameters */}} diff --git a/templates/plumbing/applications.yaml b/templates/plumbing/applications.yaml index b111e3d..40a0e1f 100644 --- a/templates/plumbing/applications.yaml +++ b/templates/plumbing/applications.yaml @@ -1,4 +1,4 @@ -{{- if ($.Values.global.deletePattern | default "0" | int | ne 1) }} {{- /* When a pattern is deleting applications should be removed */}} +{{- if ($.Values.global.deletePattern | ne "DeleteChildApps") }} {{- /* When a pattern is deleting applications should be removed */}} {{- $namespace := print $.Values.global.pattern "-" $.Values.clusterGroup.name }} {{- range .Values.clusterGroup.applications }} {{- if . }} {{- /* Skip null applications */}} diff --git a/tests/application_delete_pattern_test.yaml b/tests/application_delete_pattern_test.yaml index adf078b..1a02e2a 100644 --- a/tests/application_delete_pattern_test.yaml +++ b/tests/application_delete_pattern_test.yaml @@ -34,10 +34,10 @@ tests: isKind: of: Application - - it: should render applications when deletePattern is 0 + - it: should render applications when deletePattern is none set: global: - deletePattern: 0 + deletePattern: none clusterGroup: applications: acm: @@ -66,10 +66,10 @@ tests: isKind: of: Application - - it: should NOT render applications when deletePattern is 1 + - it: should NOT render applications when deletePattern is DeleteChildApps set: global: - deletePattern: 1 + deletePattern: DeleteChildApps clusterGroup: applications: acm: @@ -88,10 +88,10 @@ tests: - hasDocuments: count: 0 - - it: should NOT render applications when deletePattern is "1" (string) + - it: should render applications when deletePattern is set to a different phase, like DeleteSpokeChildApps set: global: - deletePattern: "1" + deletePattern: DeleteSpokeChildApps clusterGroup: applications: acm: @@ -108,33 +108,23 @@ tests: chartVersion: 0.1.* asserts: - hasDocuments: - count: 0 - - - it: should render applications when deletePattern is "0" (string) - set: - global: - deletePattern: "0" - clusterGroup: - applications: - acm: - name: acm - namespace: open-cluster-management - project: hub - chart: acm - chartVersion: 0.1.* - asserts: - - hasDocuments: - count: 1 + count: 2 - documentSelector: path: metadata.name value: acm isKind: of: Application + - documentSelector: + path: metadata.name + value: vault + isKind: + of: Application + - it: should work correctly with deletePattern when some applications are null set: global: - deletePattern: 0 + deletePattern: none clusterGroup: applications: acm: @@ -164,10 +154,10 @@ tests: isKind: of: Application - - it: should not render any applications even with null apps when deletePattern is 1 + - it: should not render any applications even with null apps when deletePattern is DeleteChildApps set: global: - deletePattern: 1 + deletePattern: DeleteChildApps clusterGroup: applications: acm: diff --git a/tests/application_multi_source_test.yaml b/tests/application_multi_source_test.yaml index 14f305a..3b2d009 100644 --- a/tests/application_multi_source_test.yaml +++ b/tests/application_multi_source_test.yaml @@ -62,7 +62,7 @@ tests: value: acm lengthEqual: path: spec.sources[1].helm.parameters - count: 15 + count: 16 - documentSelector: path: metadata.name value: vault @@ -70,7 +70,7 @@ tests: path: spec.sources[1].repoURL value: https://charts.validatedpatterns.io - - it: should render a multisource applications and its extraparameters + - it: should render a multisource applications and its 2 extraparameters set: global: repoURL: https://github.com/validatedpatterns/multicloud-gitops @@ -96,4 +96,4 @@ tests: value: acm lengthEqual: path: spec.sources[1].helm.parameters - count: 17 + count: 18 diff --git a/values.schema.json b/values.schema.json index df8e1d3..ba2ea16 100644 --- a/values.schema.json +++ b/values.schema.json @@ -198,17 +198,10 @@ "$ref": "#/definitions/GlobalSecretStore" }, "deletePattern": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "string" - } - ], + "type": "string", "readOnly": true, - "description": "Flag set by the patterns operator when a pattern CR is being deleted. When set to 1, the clustergroup chart will not render applications, allowing them to be removed before other resources. This prevents applications from becoming impossible to delete if their operators, webhooks, etc. are destroyed in the wrong order. Defaults to 0 (not deleting).", - "default": 0 + "description": "Flag set by the patterns operator when a pattern CR is being deleted. When set to DeleteChildApps, the clustergroup chart will not render applications, allowing them to be removed before other resources. This prevents applications from becoming impossible to delete if their operators, webhooks, etc. are destroyed in the wrong order. Defaults to none (not deleting).", + "default": "none" } }, "required": [