9d564898bf9a48ad5bbad6d249a29f9603f0a36e
[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-detach-profile-wft
22   namespace: osm-workflows
23
24 spec:
25   arguments:
26     parameters:
27
28     # Fleet repo
29     - name: git_fleet_url
30     - name: fleet_destination_folder
31     - name: git_fleet_cred_secret
32
33     # Specific parameters
34     - name: profile_name
35     - name: profile_type
36     - name: project_name
37       value: "osm_admin"
38     - name: cluster_kustomization_name
39
40     # Debugging
41     - name: dry_run
42       value: false
43
44
45   # # Cleanup policy
46   # ttlStrategy:
47   #   secondsAfterCompletion: 100 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
48   #   secondsAfterSuccess: 50     # Time to live after workflow is successful
49   #   secondsAfterFailure: 50     # Time to live after workflow fails
50
51   entrypoint: detach-profile
52
53   templates:
54
55   # Main template
56   - name: detach-profile
57     inputs:
58       parameters:
59       # Git repos
60       - name: git_fleet_url
61       - name: fleet_destination_folder
62       - name: git_fleet_cred_secret
63
64       # Specific parameters
65       - name: profile_name
66       - name: profile_type
67       - name: project_name
68       - name: cluster_kustomization_name
69
70       # Debugging
71       - name: dry_run
72     steps:
73
74     # ------ Preparations for transaction
75     - - name: generate-fleet-volume-repo
76         templateRef:
77           name: k8s-resources-wft
78           template: generate-volume
79         arguments:
80           parameters:
81             - name: pvc-size
82               value: '100Mi'
83     - - name: clone-fleet
84         templateRef:
85           name: git-wft
86           template: git-clone
87         arguments:
88           parameters:
89           - name: mount_path
90             value: "/fleet"
91           - name: repo_url
92             value: "{{inputs.parameters.git_fleet_url}}"
93           - name: destination_folder
94             value: "{{inputs.parameters.fleet_destination_folder}}"
95           - name: git_cred_secret
96             value: "{{inputs.parameters.git_fleet_cred_secret}}"
97           - name: git_volume_name
98             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
99     # ------ end of preparations for transaction
100
101     # ------ Transformations
102     # Detach profile from cluster
103     - - name: detach-profile
104         templateRef:
105           name: profile-management-wft
106           template: detach-profile-from-cluster
107         arguments:
108           parameters:
109           # Volumes with cloned repos
110           - name: fleet_volume_name
111             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
112           - name: fleet_mount_path
113             value: "/fleet"
114           # Specific parameters
115           - name: profile_name
116             value: "{{inputs.parameters.profile_name}}"
117           - name: profile_type
118             value: "{{inputs.parameters.profile_type}}"
119           - name: project_name
120             value: "{{inputs.parameters.project_name}}"
121           - name: fleet_repo_url
122             value: "{{inputs.parameters.git_fleet_url}}"
123           - name: cluster_kustomization_name
124             value: "{{inputs.parameters.cluster_kustomization_name}}"
125     # ------ end of transformations
126
127     # ------ Commit transaction
128     - - name: push-to-fleet
129         templateRef:
130           name: git-wft
131           template: git-commit-merge-push
132         arguments:
133           parameters:
134           - name: mount_path
135             value: "/fleet"
136           - name: repo_folder
137             value: "{{inputs.parameters.fleet_destination_folder}}"
138           - name: git_cred_secret
139             value: "{{inputs.parameters.git_fleet_cred_secret}}"
140           - name: git_volume_name
141             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
142           - name: commit_message
143             value: "Detach {{inputs.parameters.profile_name}} profile from {{inputs.parameters.cluster_kustomization_name}} cluster"
144           - name: main_branch
145             value: main
146           - name: contrib_branch
147             value: osm_contrib
148           - name: dry_run
149             value: "{{inputs.parameters.dry_run}}"
150 # ------ end of commit transaction