Skip to content
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 templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 */}}


Expand Down
2 changes: 1 addition & 1 deletion templates/plumbing/applications.yaml
Original file line number Diff line number Diff line change
@@ -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 */}}
Expand Down
42 changes: 16 additions & 26 deletions tests/application_delete_pattern_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/application_multi_source_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ tests:
value: acm
lengthEqual:
path: spec.sources[1].helm.parameters
count: 15
count: 16
- documentSelector:
path: metadata.name
value: vault
equal:
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
Expand All @@ -96,4 +96,4 @@ tests:
value: acm
lengthEqual:
path: spec.sources[1].helm.parameters
count: 17
count: 18
13 changes: 3 additions & 10 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down