ac323766079efb1f14e22423ed488b81d49ea48b
[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-clone-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     # Specific parameters - Source and destination KSU
31     ## Source KSU:
32     - name: source_ksu_name
33     - name: source_profile_name
34     - name: source_profile_type
35     - name: source_project_name
36       value: "osm_admin"
37     ## Destination KSU:
38     ## - If any of the destination parameters are not specified, it will assume
39     ##   they are the same as in source.
40     ## - It will reject if all are empty or equal to source, to avoid cloning a KSU over itself
41     - name: destination_ksu_name
42       value: ""
43     - name: destination_profile_name
44       value: ""
45     - name: destination_profile_type
46       value: ""
47     - name: destination_project_name
48       value: ""
49     # Debug/dry run?
50     - name: debug
51       value: "false"
52     - name: dry_run
53       value: "false"
54
55   # Cleanup policy
56   ttlStrategy:
57     secondsAfterCompletion: 6000  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
58     secondsAfterSuccess: 6000     # Time to live after workflow is successful
59     secondsAfterFailure: 9000     # Time to live after workflow fails
60
61   entrypoint: clone-ksu
62
63   templates:
64   # Main template
65   - name: clone-ksu
66     inputs:
67       parameters:
68       # Fleet repo
69       - name: git_fleet_url
70       - name: fleet_destination_folder
71       - name: git_fleet_cred_secret
72       # Specific parameters - Source and destination KSU
73       ## Source KSU:
74       - name: source_ksu_name
75       - name: source_profile_name
76       - name: source_profile_type
77       - name: source_project_name
78       ## Destination KSU:
79       - name: destination_ksu_name
80       - name: destination_profile_name
81       - name: destination_profile_type
82       - name: destination_project_name
83       # Debug/dry run?
84       - name: debug
85       - name: dry_run
86
87     steps:
88     # ------ Preparations for transaction
89     - - name: generate-fleet-volume-repo
90         templateRef:
91           name: k8s-resources-wft
92           template: generate-volume
93         arguments:
94           parameters:
95             - name: pvc-size
96               value: '100Mi'
97       - name: generate-sw-catalogs-volume-repo
98         templateRef:
99           name: k8s-resources-wft
100           template: generate-volume
101         arguments:
102           parameters:
103             - name: pvc-size
104               value: '100Mi'
105     - - name: clone-fleet
106         templateRef:
107           name: git-wft
108           template: git-clone
109         arguments:
110           parameters:
111           - name: mount_path
112             value: "/fleet"
113           - name: repo_url
114             value: "{{inputs.parameters.git_fleet_url}}"
115           - name: destination_folder
116             value: "{{inputs.parameters.fleet_destination_folder}}"
117           - name: git_cred_secret
118             value: "{{inputs.parameters.git_fleet_cred_secret}}"
119           - name: git_volume_name
120             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
121     # ------ end of preparations for transaction
122
123     # ------ Transformations
124     - - name: clone-ksu
125         templateRef:
126           name: ksu-management-wft
127           template: clone-ksu
128         arguments:
129           parameters:
130           # References to required external resources
131           - name: fleet_volume_name
132             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
133           # Specific parameters - Source and destination KSU
134           ## Source KSU:
135           - name: source_ksu_name
136             value: "{{inputs.parameters.source_ksu_name}}"
137           - name: source_profile_name
138             value: "{{inputs.parameters.source_profile_name}}"
139           - name: source_profile_type
140             value: "{{inputs.parameters.source_profile_type}}"
141           - name: source_project_name
142             value: "{{inputs.parameters.source_project_name}}"
143           ## Destination KSU:
144           - name: destination_ksu_name
145             value: "{{inputs.parameters.destination_ksu_name}}"
146           - name: destination_profile_name
147             value: "{{inputs.parameters.destination_profile_name}}"
148           - name: destination_profile_type
149             value: "{{inputs.parameters.destination_profile_type}}"
150           - name: destination_project_name
151             value: "{{inputs.parameters.destination_project_name}}"
152           # Debug?
153           - name: debug
154             value: "{{inputs.parameters.debug}}"
155     # ------ end of transformations
156
157     # ------ Commit transaction
158     - - name: push-to-fleet
159         templateRef:
160           name: git-wft
161           template: git-commit-merge-push
162         arguments:
163           parameters:
164           - name: mount_path
165             value: "/fleet"
166           - name: repo_folder
167             value: "{{inputs.parameters.fleet_destination_folder}}"
168           - name: git_cred_secret
169             value: "{{inputs.parameters.git_fleet_cred_secret}}"
170           - name: git_volume_name
171             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
172           - name: commit_message
173             value: "Clone KSU {{inputs.parameters.source_ksu_name}} at {{inputs.parameters.source_profile_name}} profile of {{inputs.parameters.source_profile_type}} type @ {{inputs.parameters.source_project_name}} project as {{inputs.parameters.destination_ksu_name}} KSU at {{inputs.parameters.destination_profile_name}} profile of {{inputs.parameters.destination_profile_type}} type @ {{inputs.parameters.destination_project_name}}"
174           - name: main_branch
175             value: main
176           - name: contrib_branch
177             value: osm_contrib
178           - name: dry_run
179             value: "{{inputs.parameters.dry_run}}"
180 # ------ end of commit transaction