3d35084ec28bcc1ce359c17edbd3f0d8535e1d88
[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-update-ksu-hr-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 - Base KSU generation from template
35     ## Relative path from "SW Catalogs" repo root
36     - name: templates_path
37     ## Should substitute environment variables in the template?
38     - name: substitute_environment
39     ## Filter for substitution of environment variables
40     - name: substitution_filter
41     ## Custom environment variables (formatted as .env), to be used for template parametrization
42     - name: custom_env_vars
43     # Specific parameters - Patch HelmRelease in KSU with inline values
44     - name: kustomization_name
45     - name: helmrelease_name
46     - name: inline_values
47     # Specific parameters - Secret generation
48     - name: is_preexisting_secret
49     - name: target_ns
50     - name: age_public_key
51     - name: values_secret_name
52     - name: secret_key
53       value: "values.yaml"
54     ################################################################
55     # This temporary secret should exist already in the `osm-workflows`
56     # namespace and contain the desired secret key-values
57     # in a well-known key (in the example, `creds`).
58     #
59     # For instance:
60     #
61     # creds: |
62     #     jenkinsUser: admin
63     #     jenkinsPassword: myJ3nk1n2P2ssw0rd
64     - name: reference_secret_for_values
65     - name: reference_key_for_values
66     # Specific parameters - Configmap generation
67     - name: is_preexisting_cm
68     - name: values_cm_name
69     - name: cm_key
70       value: "values.yaml"
71     - name: cm_values
72       value: ""
73     # Specific parameters - KSU rendering
74     - name: ksu_name
75     - name: profile_name
76     - name: profile_type
77     - name: project_name
78       value: "osm_admin"
79     # Debug/dry run?
80     - name: debug
81       value: "false"
82     - name: dry_run
83       value: "false"
84
85   # Cleanup policy
86   ttlStrategy:
87     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
88     secondsAfterSuccess: 6000     # Time to live after workflow is successful
89     secondsAfterFailure: 9000     # Time to live after workflow fails
90
91   entrypoint: update-ksu-hr
92
93   templates:
94   # Main template
95   - name: update-ksu-hr
96     inputs:
97       parameters:
98       # Fleet repo
99       - name: git_fleet_url
100       - name: fleet_destination_folder
101       - name: git_fleet_cred_secret
102       # SW-Catalogs repo
103       - name: git_sw_catalogs_url
104       - name: sw_catalogs_destination_folder
105       - name: git_sw_catalogs_cred_secret
106       # Specific parameters - Base KSU generation from template
107       - name: templates_path
108       - name: substitute_environment
109       - name: substitution_filter
110       - name: custom_env_vars
111       # Specific parameters - Patch HelmRelease in KSU with inline values
112       - name: kustomization_name
113       - name: helmrelease_name
114       - name: inline_values
115       # Specific parameters - Secret generation
116       - name: is_preexisting_secret
117       - name: target_ns
118       - name: age_public_key
119       - name: values_secret_name
120       - name: reference_secret_for_values
121       - name: reference_key_for_values
122       - name: secret_key
123       # Specific parameters - Configmap generation
124       - name: is_preexisting_cm
125       - name: values_cm_name
126       - name: cm_key
127       - name: cm_values
128       # Specific parameters - KSU rendering
129       - name: ksu_name
130       - name: profile_name
131       - name: profile_type
132       - name: project_name
133       # Debug/dry run?
134       - name: debug
135       - name: dry_run
136
137     steps:
138     # ------ Preparations for transaction
139     - - name: generate-fleet-volume-repo
140         templateRef:
141           name: k8s-resources-wft
142           template: generate-volume
143         arguments:
144           parameters:
145             - name: pvc-size
146               value: '100Mi'
147       - name: generate-sw-catalogs-volume-repo
148         templateRef:
149           name: k8s-resources-wft
150           template: generate-volume
151         arguments:
152           parameters:
153             - name: pvc-size
154               value: '100Mi'
155     - - name: clone-fleet
156         templateRef:
157           name: git-wft
158           template: git-clone
159         arguments:
160           parameters:
161           - name: mount_path
162             value: "/fleet"
163           - name: repo_url
164             value: "{{inputs.parameters.git_fleet_url}}"
165           - name: destination_folder
166             value: "{{inputs.parameters.fleet_destination_folder}}"
167           - name: git_cred_secret
168             value: "{{inputs.parameters.git_fleet_cred_secret}}"
169           - name: git_volume_name
170             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
171       - name: clone-sw-catalogs
172         templateRef:
173           name: git-wft
174           template: git-clone
175         arguments:
176           parameters:
177           - name: mount_path
178             value: "/sw-catalogs"
179           - name: repo_url
180             value: "{{inputs.parameters.git_sw_catalogs_url}}"
181           - name: destination_folder
182             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
183           - name: git_cred_secret
184             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
185           - name: git_volume_name
186             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
187     # ------ end of preparations for transaction
188
189     # ------ Transformations
190     - - name: update-ksu-oka-hr
191         templateRef:
192           name: ksu-management-wft
193           template: update-ksu-oka-hr
194         arguments:
195           parameters:
196           # References to required external resources
197           - name: fleet_volume_name
198             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
199           - name: sw_catalogs_volume_name
200             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
201           # Specific parameters - Base KSU generation from template
202           - name: templates_path
203             value: "{{inputs.parameters.templates_path}}"
204           - name: substitute_environment
205             value: "{{inputs.parameters.substitute_environment}}"
206           - name: substitution_filter
207             value: "{{inputs.parameters.substitution_filter}}"
208           - name: custom_env_vars
209             value: "{{inputs.parameters.custom_env_vars}}"
210           # Specific parameters - Patch HelmRelease in KSU with inline values
211           - name: kustomization_name
212             value: "{{inputs.parameters.kustomization_name}}"
213           - name: helmrelease_name
214             value: "{{inputs.parameters.helmrelease_name}}"
215           - name: inline_values
216             value: "{{inputs.parameters.inline_values}}"
217           # Specific parameters - Secret generation
218           - name: is_preexisting_secret
219             value: "{{inputs.parameters.is_preexisting_secret}}"
220           - name: target_ns
221             value: "{{inputs.parameters.target_ns}}"
222           - name: age_public_key
223             value: "{{inputs.parameters.age_public_key}}"
224           - name: values_secret_name
225             value: "{{inputs.parameters.values_secret_name}}"
226           - name: reference_secret_for_values
227             value: "{{inputs.parameters.reference_secret_for_values}}"
228           - name: reference_key_for_values
229             value: "{{inputs.parameters.reference_key_for_values}}"
230           - name: secret_key
231             value: "{{inputs.parameters.secret_key}}"
232           # Specific parameters - Configmap generation
233           - name: is_preexisting_cm
234             value: "{{inputs.parameters.is_preexisting_cm}}"
235           - name: values_cm_name
236             value: "{{inputs.parameters.values_cm_name}}"
237           - name: cm_key
238             value: "{{inputs.parameters.cm_key}}"
239           - name: cm_values
240             value: "{{inputs.parameters.cm_values}}"
241           # Specific parameters - KSU rendering
242           - name: ksu_name
243             value: "{{inputs.parameters.ksu_name}}"
244           - name: profile_name
245             value: "{{inputs.parameters.profile_name}}"
246           - name: profile_type
247             value: "{{inputs.parameters.profile_type}}"
248           - name: project_name
249             value: "{{inputs.parameters.project_name}}"
250           # Debug?
251           - name: debug
252             value: "{{inputs.parameters.debug}}"
253     # ------ end of transformations
254
255     # ------ Commit transaction
256     - - name: push-to-fleet
257         templateRef:
258           name: git-wft
259           template: git-commit-merge-push
260         arguments:
261           parameters:
262           - name: mount_path
263             value: "/fleet"
264           - name: repo_folder
265             value: "{{inputs.parameters.fleet_destination_folder}}"
266           - name: git_cred_secret
267             value: "{{inputs.parameters.git_fleet_cred_secret}}"
268           - name: git_volume_name
269             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
270           - name: commit_message
271             value: "Update KSU {{inputs.parameters.ksu_name}} of {{inputs.parameters.profile_name}} profile of {{inputs.parameters.profile_type}} type @ {{inputs.parameters.project_name}} project"
272           - name: main_branch
273             value: main
274           - name: contrib_branch
275             value: osm_contrib
276           - name: dry_run
277             value: "{{inputs.parameters.dry_run}}"
278 # ------ end of commit transaction