b90421820f7c3aab35b48ad68bfa5ccfa0ce5ca9
[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-create-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     # By default, it will re-create the full KSU folder
80     - name: sync
81       version: "true"
82     # Debug/dry run?
83     - name: debug
84       value: "false"
85     - name: dry_run
86       value: "false"
87
88   # Cleanup policy
89   ttlStrategy:
90     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
91     secondsAfterSuccess: 6000     # Time to live after workflow is successful
92     secondsAfterFailure: 9000     # Time to live after workflow fails
93
94   entrypoint: create-ksu-hr
95
96   templates:
97   # Main template
98   - name: create-ksu-hr
99     inputs:
100       parameters:
101       # Fleet repo
102       - name: git_fleet_url
103       - name: fleet_destination_folder
104       - name: git_fleet_cred_secret
105       # SW-Catalogs repo
106       - name: git_sw_catalogs_url
107       - name: sw_catalogs_destination_folder
108       - name: git_sw_catalogs_cred_secret
109       # Specific parameters - Base KSU generation from template
110       - name: templates_path
111       - name: substitute_environment
112       - name: substitution_filter
113       - name: custom_env_vars
114       # Specific parameters - Patch HelmRelease in KSU with inline values
115       - name: kustomization_name
116       - name: helmrelease_name
117       - name: inline_values
118       # Specific parameters - Secret generation
119       - name: is_preexisting_secret
120       - name: target_ns
121       - name: age_public_key
122       - name: values_secret_name
123       - name: reference_secret_for_values
124       - name: reference_key_for_values
125       - name: secret_key
126       # Specific parameters - Configmap generation
127       - name: is_preexisting_cm
128       - name: values_cm_name
129       - name: cm_key
130       - name: cm_values
131       # Specific parameters - KSU rendering
132       - name: ksu_name
133       - name: profile_name
134       - name: profile_type
135       - name: project_name
136       - name: sync
137       # Debug/dry run?
138       - name: debug
139       - name: dry_run
140
141     steps:
142     # ------ Preparations for transaction
143     - - name: generate-fleet-volume-repo
144         templateRef:
145           name: k8s-resources-wft
146           template: generate-volume
147         arguments:
148           parameters:
149             - name: pvc-size
150               value: '100Mi'
151       - name: generate-sw-catalogs-volume-repo
152         templateRef:
153           name: k8s-resources-wft
154           template: generate-volume
155         arguments:
156           parameters:
157             - name: pvc-size
158               value: '100Mi'
159     - - name: clone-fleet
160         templateRef:
161           name: git-wft
162           template: git-clone
163         arguments:
164           parameters:
165           - name: mount_path
166             value: "/fleet"
167           - name: repo_url
168             value: "{{inputs.parameters.git_fleet_url}}"
169           - name: destination_folder
170             value: "{{inputs.parameters.fleet_destination_folder}}"
171           - name: git_cred_secret
172             value: "{{inputs.parameters.git_fleet_cred_secret}}"
173           - name: git_volume_name
174             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
175       - name: clone-sw-catalogs
176         templateRef:
177           name: git-wft
178           template: git-clone
179         arguments:
180           parameters:
181           - name: mount_path
182             value: "/sw-catalogs"
183           - name: repo_url
184             value: "{{inputs.parameters.git_sw_catalogs_url}}"
185           - name: destination_folder
186             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
187           - name: git_cred_secret
188             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
189           - name: git_volume_name
190             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
191     # ------ end of preparations for transaction
192
193     # ------ Transformations
194     - - name: create-ksu-oka-hr
195         templateRef:
196           name: ksu-management-wft
197           template: create-ksu-oka-hr
198         arguments:
199           parameters:
200           # References to required external resources
201           - name: fleet_volume_name
202             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
203           - name: sw_catalogs_volume_name
204             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
205           # Specific parameters - Base KSU generation from template
206           - name: templates_path
207             value: "{{inputs.parameters.templates_path}}"
208           - name: substitute_environment
209             value: "{{inputs.parameters.substitute_environment}}"
210           - name: substitution_filter
211             value: "{{inputs.parameters.substitution_filter}}"
212           - name: custom_env_vars
213             value: "{{inputs.parameters.custom_env_vars}}"
214           # Specific parameters - Patch HelmRelease in KSU with inline values
215           - name: kustomization_name
216             value: "{{inputs.parameters.kustomization_name}}"
217           - name: helmrelease_name
218             value: "{{inputs.parameters.helmrelease_name}}"
219           - name: inline_values
220             value: "{{inputs.parameters.inline_values}}"
221           # Specific parameters - Secret generation
222           - name: is_preexisting_secret
223             value: "{{inputs.parameters.is_preexisting_secret}}"
224           - name: target_ns
225             value: "{{inputs.parameters.target_ns}}"
226           - name: age_public_key
227             value: "{{inputs.parameters.age_public_key}}"
228           - name: values_secret_name
229             value: "{{inputs.parameters.values_secret_name}}"
230           - name: reference_secret_for_values
231             value: "{{inputs.parameters.reference_secret_for_values}}"
232           - name: reference_key_for_values
233             value: "{{inputs.parameters.reference_key_for_values}}"
234           - name: secret_key
235             value: "{{inputs.parameters.secret_key}}"
236           # Specific parameters - Configmap generation
237           - name: is_preexisting_cm
238             value: "{{inputs.parameters.is_preexisting_cm}}"
239           - name: values_cm_name
240             value: "{{inputs.parameters.values_cm_name}}"
241           - name: cm_key
242             value: "{{inputs.parameters.cm_key}}"
243           - name: cm_values
244             value: "{{inputs.parameters.cm_values}}"
245           # Specific parameters - KSU rendering
246           - name: ksu_name
247             value: "{{inputs.parameters.ksu_name}}"
248           - name: profile_name
249             value: "{{inputs.parameters.profile_name}}"
250           - name: profile_type
251             value: "{{inputs.parameters.profile_type}}"
252           - name: project_name
253             value: "{{inputs.parameters.project_name}}"
254           - name: sync
255             value: "{{inputs.parameters.sync}}"
256           # Debug?
257           - name: debug
258             value: "{{inputs.parameters.debug}}"
259     # ------ end of transformations
260
261     # ------ Commit transaction
262     - - name: push-to-fleet
263         templateRef:
264           name: git-wft
265           template: git-commit-merge-push
266         arguments:
267           parameters:
268           - name: mount_path
269             value: "/fleet"
270           - name: repo_folder
271             value: "{{inputs.parameters.fleet_destination_folder}}"
272           - name: git_cred_secret
273             value: "{{inputs.parameters.git_fleet_cred_secret}}"
274           - name: git_volume_name
275             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
276           - name: commit_message
277             value: "Create KSU {{inputs.parameters.ksu_name}} into {{inputs.parameters.profile_name}} profile of {{inputs.parameters.profile_type}} type @ {{inputs.parameters.project_name}} project"
278           - name: main_branch
279             value: main
280           - name: contrib_branch
281             value: osm_contrib
282           - name: dry_run
283             value: "{{inputs.parameters.dry_run}}"
284 # ------ end of commit transaction