7ef0dc220dbc3f3f836e6b738c0b98a43116367e
[osm/devops.git] /
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 apiVersion: argoproj.io/v1alpha1
19 kind: WorkflowTemplate
20 metadata:
21   name: full-delete-cluster-wft
22   namespace: osm-workflows
23
24 spec:
25   arguments:
26     parameters:
27
28     # Fleet repo
29     - name: git_fleet_url
30     - name: fleet_destination_folder
31     - name: git_fleet_cred_secret
32
33     # Specific parameters
34     - name: cluster_kustomization_name
35     - name: project_name
36       value: "osm_admin"
37
38     # Debugging
39     - name: dry_run
40       value: false
41
42
43   # # Cleanup policy
44   # ttlStrategy:
45   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
46   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
47   #   secondsAfterFailure: 50     # Time to live after workflow fails
48
49   entrypoint: delete-cluster
50
51   templates:
52
53   # Main template
54   - name: delete-cluster
55     inputs:
56       parameters:
57       # Git repos
58       - name: git_fleet_url
59       - name: fleet_destination_folder
60       - name: git_fleet_cred_secret
61
62       # Specific parameters
63       - name: cluster_kustomization_name
64       - name: project_name
65
66       # Debugging
67       - name: dry_run
68
69     steps:
70
71     # ------ Preparations for transaction
72     - - name: generate-fleet-volume-repo
73         templateRef:
74           name: k8s-resources-wft
75           template: generate-volume
76         arguments:
77           parameters:
78             - name: pvc-size
79               value: '100Mi'
80     - - name: clone-fleet
81         templateRef:
82           name: git-wft
83           template: git-clone
84         arguments:
85           parameters:
86           - name: mount_path
87             value: "/fleet"
88           - name: repo_url
89             value: "{{inputs.parameters.git_fleet_url}}"
90           - name: destination_folder
91             value: "{{inputs.parameters.fleet_destination_folder}}"
92           - name: git_cred_secret
93             value: "{{inputs.parameters.git_fleet_cred_secret}}"
94           - name: git_volume_name
95             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
96     # ------ end of preparations for transaction
97
98     # ------ Transformations
99     - - name: delete-cluster
100         templateRef:
101           name: cluster-management-wft
102           template: delete-cluster
103         arguments:
104           parameters:
105           # Volumes with cloned repos
106           - name: fleet_volume_name
107             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
108           - name: fleet_mount_path
109             value: "/fleet"
110           # Specific parameters
111           - name: cluster_kustomization_name
112             value: "{{inputs.parameters.cluster_kustomization_name}}"
113           - name: project_name
114             value: "{{inputs.parameters.project_name}}"
115     # ------ end of transformations
116
117     # ------ Commit transaction
118     - - name: push-to-fleet
119         templateRef:
120           name: git-wft
121           template: git-commit-merge-push
122         arguments:
123           parameters:
124           - name: mount_path
125             value: "/fleet"
126           - name: repo_folder
127             value: "{{inputs.parameters.fleet_destination_folder}}"
128           - name: git_cred_secret
129             value: "{{inputs.parameters.git_fleet_cred_secret}}"
130           - name: git_volume_name
131             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
132           - name: commit_message
133             value: "Delete cluster {{inputs.parameters.cluster_kustomization_name}}"
134           - name: main_branch
135             value: main
136           - name: contrib_branch
137             value: osm_contrib
138           - name: dry_run
139             value: "{{inputs.parameters.dry_run}}"
140 # ------ end of commit transaction