6e17e9b29658a1251116ace097d3168184d90401
[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-crossplane-providerconfig
22   namespace: osm-workflows
23
24 spec:
25   arguments:
26     parameters:
27     # Fleet repo
28     - name: git_fleet_url
29     - name: fleet_destination_folder
30     - name: git_fleet_cred_secret
31     # SW-Catalogs repo
32     - name: git_sw_catalogs_url
33     - name: sw_catalogs_destination_folder
34     - name: git_sw_catalogs_cred_secret
35
36     # Specific parameters
37     - name: providerconfig_name
38     ## As of today, one among `azure`, `aws` or `gcp`
39     - name: provider_type
40     ## Final secret to reference from the `ProviderConfig`
41     - name: cred_secret_name
42     ## Temporary secret with secret contents for the workflow
43     ## - If `temp_cred_secret_name` is empty, assumes that the final secret already exists
44     - name: temp_cred_secret_name
45       value: ""
46     - name: temp_cred_secret_key
47       value: "creds"
48     - name: age_public_key_mgmt
49     - name: osm_project_name
50       value: "osm_admin"
51     ## Specific parameters - GCP only
52     - name: target_gcp_project
53       value: ""
54     # Debug/dry run?
55     - name: debug
56       value: "false"
57     - name: dry_run
58       value: "false"
59
60   # Cleanup policy
61   ttlStrategy:
62     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
63     secondsAfterSuccess: 6000     # Time to live after workflow is successful
64     secondsAfterFailure: 9000     # Time to live after workflow fails
65
66   entrypoint: update-crossplane-providerconfig
67
68   templates:
69
70   # Main template
71   - name: update-crossplane-providerconfig
72     inputs:
73       parameters:
74       # Fleet repo
75       - name: git_fleet_url
76       - name: fleet_destination_folder
77       - name: git_fleet_cred_secret
78       # SW-Catalogs repo
79       - name: git_sw_catalogs_url
80       - name: sw_catalogs_destination_folder
81       - name: git_sw_catalogs_cred_secret
82       # Specific parameters
83       - name: providerconfig_name
84       - name: provider_type
85       - name: cred_secret_name
86       - name: temp_cred_secret_name
87       - name: temp_cred_secret_key
88       - name: age_public_key_mgmt
89       - name: osm_project_name
90       - name: target_gcp_project
91       # Debug/dry run?
92       - name: debug
93         value: "false"
94       - name: dry_run
95         value: "false"
96
97     steps:
98
99     # ------ Preparations for transaction
100     - - name: generate-fleet-volume-repo
101         templateRef:
102           name: k8s-resources-wft
103           template: generate-volume
104         arguments:
105           parameters:
106             - name: pvc-size
107               value: '100Mi'
108       - name: generate-sw-catalogs-volume-repo
109         templateRef:
110           name: k8s-resources-wft
111           template: generate-volume
112         arguments:
113           parameters:
114             - name: pvc-size
115               value: '100Mi'
116     - - name: clone-fleet
117         templateRef:
118           name: git-wft
119           template: git-clone
120         arguments:
121           parameters:
122           - name: mount_path
123             value: "/fleet"
124           - name: repo_url
125             value: "{{inputs.parameters.git_fleet_url}}"
126           - name: destination_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: clone-sw-catalogs
133         templateRef:
134           name: git-wft
135           template: git-clone
136         arguments:
137           parameters:
138           - name: mount_path
139             value: "/sw-catalogs"
140           - name: repo_url
141             value: "{{inputs.parameters.git_sw_catalogs_url}}"
142           - name: destination_folder
143             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
144           - name: git_cred_secret
145             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
146           - name: git_volume_name
147             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
148     # ------ end of preparations for transaction
149
150     # ------ Transformations
151     - - name: update-crossplane-providerconfig
152         templateRef:
153           name: cloud-accounts-wft
154           template: update-crossplane-providerconfig
155         arguments:
156           parameters:
157           # References to required external resources
158           - name: fleet_volume_name
159             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
160           - name: sw_catalogs_volume_name
161             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
162           # Specific parameters
163           - name: providerconfig_name
164             value: "{{inputs.parameters.providerconfig_name}}"
165           - name: provider_type
166             value: "{{inputs.parameters.provider_type}}"
167           - name: cred_secret_name
168             value: "{{inputs.parameters.cred_secret_name}}"
169           - name: temp_cred_secret_name
170             value: "{{inputs.parameters.temp_cred_secret_name}}"
171           - name: temp_cred_secret_key
172             value: "{{inputs.parameters.temp_cred_secret_key}}"
173           - name: age_public_key_mgmt
174             value: "{{inputs.parameters.age_public_key_mgmt}}"
175           - name: osm_project_name
176             value: "{{inputs.parameters.osm_project_name}}"
177           - name: target_gcp_project
178             value: "{{inputs.parameters.target_gcp_project}}"
179           # Debug?
180           - name: debug
181             value: "{{inputs.parameters.debug}}"
182     # ------ end of transformations
183
184     # ------ Commit transaction
185     - - name: push-to-fleet
186         templateRef:
187           name: git-wft
188           template: git-commit-merge-push
189         arguments:
190           parameters:
191           - name: mount_path
192             value: "/fleet"
193           - name: repo_folder
194             value: "{{inputs.parameters.fleet_destination_folder}}"
195           - name: git_cred_secret
196             value: "{{inputs.parameters.git_fleet_cred_secret}}"
197           - name: git_volume_name
198             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
199           - name: commit_message
200             value: "Update ProviderConfig {{inputs.parameters.providerconfig_name}} for {{inputs.parameters.provider_type}}"
201           - name: main_branch
202             value: main
203           - name: contrib_branch
204             value: osm_contrib
205           - name: dry_run
206             value: "{{inputs.parameters.dry_run}}"
207 # ------ end of commit transaction