b933cc926962a8fdb67a79d1212c2090ccf6276e
[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-ksu-wtf
22   namespace: osm-workflows
23 spec:
24   arguments:
25     parameters:
26     # Fleet repo
27     - name: git_fleet_url
28     - name: fleet_destination_folder
29     - name: git_fleet_cred_secret
30     # SW-Catalogs repo
31     - name: git_sw_catalogs_url
32     - name: sw_catalogs_destination_folder
33     - name: git_sw_catalogs_cred_secret
34     # Specific parameters - KSU id
35     - name: ksu_name
36     - name: profile_name
37     - name: profile_type
38     - name: project_name
39     # Debug/dry run?
40     - name: debug
41       value: "false"
42     - name: dry_run
43       value: "false"
44
45   # Cleanup policy
46   ttlStrategy:
47     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
48     secondsAfterSuccess: 6000     # Time to live after workflow is successful
49     secondsAfterFailure: 9000     # Time to live after workflow fails
50
51   entrypoint: delete-ksu
52
53   templates:
54   # Main template
55   - name: delete-ksu
56     inputs:
57       parameters:
58       # Fleet repo
59       - name: git_fleet_url
60       - name: fleet_destination_folder
61       - name: git_fleet_cred_secret
62       # SW-Catalogs repo
63       - name: git_sw_catalogs_url
64       - name: sw_catalogs_destination_folder
65       - name: git_sw_catalogs_cred_secret
66       # Specific parameters - KSU id
67       - name: ksu_name
68       - name: profile_name
69       - name: profile_type
70       - name: project_name
71       # Debug/dry run?
72       - name: debug
73       - name: dry_run
74
75     steps:
76     # ------ Preparations for transaction
77     - - name: generate-fleet-volume-repo
78         templateRef:
79           name: k8s-resources-wft
80           template: generate-volume
81         arguments:
82           parameters:
83             - name: pvc-size
84               value: '100Mi'
85       - name: generate-sw-catalogs-volume-repo
86         templateRef:
87           name: k8s-resources-wft
88           template: generate-volume
89         arguments:
90           parameters:
91             - name: pvc-size
92               value: '100Mi'
93     - - name: clone-fleet
94         templateRef:
95           name: git-wft
96           template: git-clone
97         arguments:
98           parameters:
99           - name: mount_path
100             value: "/fleet"
101           - name: repo_url
102             value: "{{inputs.parameters.git_fleet_url}}"
103           - name: destination_folder
104             value: "{{inputs.parameters.fleet_destination_folder}}"
105           - name: git_cred_secret
106             value: "{{inputs.parameters.git_fleet_cred_secret}}"
107           - name: git_volume_name
108             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
109       - name: clone-sw-catalogs
110         templateRef:
111           name: git-wft
112           template: git-clone
113         arguments:
114           parameters:
115           - name: mount_path
116             value: "/sw-catalogs"
117           - name: repo_url
118             value: "{{inputs.parameters.git_sw_catalogs_url}}"
119           - name: destination_folder
120             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
121           - name: git_cred_secret
122             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
123           - name: git_volume_name
124             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
125     # ------ end of preparations for transaction
126
127     # ------ Transformations
128     - - name: delete-ksu
129         templateRef:
130           name: ksu-management-wft
131           template: delete-ksu
132         arguments:
133           parameters:
134           # References to required external resources
135           - name: fleet_volume_name
136             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
137           - name: sw_catalogs_volume_name
138             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
139           # Specific parameters - KSU id
140           - name: ksu_name
141             value: "{{inputs.parameters.ksu_name}}"
142           - name: profile_name
143             value: "{{inputs.parameters.profile_name}}"
144           - name: profile_type
145             value: "{{inputs.parameters.profile_type}}"
146           - name: project_name
147             value: "{{inputs.parameters.project_name}}"
148           # Debug?
149           - name: debug
150             value: "{{inputs.parameters.debug}}"
151     # ------ end of transformations
152
153     # ------ Commit transaction
154     - - name: push-to-fleet
155         templateRef:
156           name: git-wft
157           template: git-commit-merge-push
158         arguments:
159           parameters:
160           - name: mount_path
161             value: "/fleet"
162           - name: repo_folder
163             value: "{{inputs.parameters.fleet_destination_folder}}"
164           - name: git_cred_secret
165             value: "{{inputs.parameters.git_fleet_cred_secret}}"
166           - name: git_volume_name
167             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
168           - name: commit_message
169             value: "Delete KSU {{inputs.parameters.ksu_name}} from {{inputs.parameters.profile_name}} profile of {{inputs.parameters.profile_type}} type @ {{inputs.parameters.project_name}} project"
170           - name: main_branch
171             value: main
172           - name: contrib_branch
173             value: osm_contrib
174           - name: dry_run
175             value: "{{inputs.parameters.dry_run}}"
176 # ------ end of commit transaction