dd563d953ac095091e353f2f5fec39eee7e18e71
[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-oka-wtf
22   namespace: osm-workflows
23 spec:
24   arguments:
25     parameters:
26     # SW-Catalogs repo
27     - name: git_sw_catalogs_url
28     - name: sw_catalogs_destination_folder
29     - name: git_sw_catalogs_cred_secret
30     # Temporary volume with OKA contents
31     - name: temp_volume_name
32     # Specific parameters - OKA
33     - name: oka_name
34     ## Choose among `infra-controllers`, `infra-configs`, `cloud-resources`, `apps`:
35     - name: oka_type
36     - name: project_name
37       value: "osm_admin"
38     - name: tarball_file
39       value: "true"
40     # Debug/dry run?
41     - name: debug
42       value: "false"
43     - name: dry_run
44       value: "false"
45
46   # Cleanup policy
47   ttlStrategy:
48     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
49     secondsAfterSuccess: 6000     # Time to live after workflow is successful
50     secondsAfterFailure: 9000     # Time to live after workflow fails
51
52   entrypoint: update-oka
53
54   templates:
55   # Main template
56   - name: update-oka
57     inputs:
58       parameters:
59       - name: git_sw_catalogs_url
60       - name: sw_catalogs_destination_folder
61       - name: git_sw_catalogs_cred_secret
62       - name: temp_volume_name
63       - name: oka_name
64       - name: oka_type
65       - name: project_name
66       - name: tarball_file
67       - name: debug
68       - name: dry_run
69     steps:
70     # ------ Preparations for transaction
71     - - name: generate-sw-catalogs-volume-repo
72         templateRef:
73           name: k8s-resources-wft
74           template: generate-volume
75         arguments:
76           parameters:
77             - name: pvc-size
78               value: '100Mi'
79     - - name: clone-sw-catalogs
80         templateRef:
81           name: git-wft
82           template: git-clone
83         arguments:
84           parameters:
85           - name: mount_path
86             value: "/sw-catalogs"
87           - name: repo_url
88             value: "{{inputs.parameters.git_sw_catalogs_url}}"
89           - name: destination_folder
90             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
91           - name: git_cred_secret
92             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
93           - name: git_volume_name
94             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
95     # ------ end of preparations for transaction
96
97     # ------ Transformations
98     - - name: update-oka
99         templateRef:
100           name: oka-management-wft
101           template: update-oka
102         arguments:
103           parameters:
104           # References to required external resources
105           - name: sw_catalogs_volume_name
106             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
107           - name: temp_volume_name
108             value: "{{inputs.parameters.temp_volume_name}}"
109           # Specific parameters
110           - name: oka_name
111             value: "{{inputs.parameters.oka_name}}"
112           - name: oka_type
113             value: "{{inputs.parameters.oka_type}}"
114           - name: project_name
115             value: "{{inputs.parameters.project_name}}"
116           - name: tarball_file
117             value: "{{inputs.parameters.tarball_file}}"
118           # Debug?
119           - name: debug
120             value: "{{inputs.parameters.debug}}"
121     # ------ end of transformations
122
123     # ------ Commit transaction
124     - - name: push-to-sw-catalogs
125         templateRef:
126           name: git-wft
127           template: git-commit-merge-push
128         arguments:
129           parameters:
130           - name: mount_path
131             value: "/sw-catalogs"
132           - name: repo_folder
133             value: "{{inputs.parameters.sw_catalogs_destination_folder}}"
134           - name: git_cred_secret
135             value: "{{inputs.parameters.git_sw_catalogs_cred_secret}}"
136           - name: git_volume_name
137             value: '{{steps.generate-sw-catalogs-volume-repo.outputs.parameters.pvc-name}}'
138           - name: commit_message
139             value: "Update OKA {{inputs.parameters.oka_name}} of {{inputs.parameters.oka_type}} type @ {{inputs.parameters.project_name}} project"
140           - name: main_branch
141             value: main
142           - name: contrib_branch
143             value: osm_contrib
144           - name: dry_run
145             value: "{{inputs.parameters.dry_run}}"
146 # ------ end of commit transaction