d2daa5bce51050fe04248cd7bbc0845a7e067ca7
[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-disconnect-flux-remote-cluster-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: cluster_kustomization_name
35     - name: mgmt_project_name
36       value: "osm_admin"
37
38     # Debug/dry run?
39     - name: debug
40       value: "false"
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: disconnect-remote-cluster
52
53   templates:
54
55   # Main template
56   - name: disconnect-remote-cluster
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: cluster_kustomization_name
66       - name: mgmt_project_name
67
68       # Debugging
69       - name: debug
70       - name: dry_run
71     steps:
72
73     # ------ Preparations for transaction
74     - - name: generate-fleet-volume-repo
75         templateRef:
76           name: k8s-resources-wft
77           template: generate-volume
78         arguments:
79           parameters:
80             - name: pvc-size
81               value: '100Mi'
82     - - name: clone-fleet
83         templateRef:
84           name: git-wft
85           template: git-clone
86         arguments:
87           parameters:
88           - name: mount_path
89             value: "/fleet"
90           - name: repo_url
91             value: "{{inputs.parameters.git_fleet_url}}"
92           - name: destination_folder
93             value: "{{inputs.parameters.fleet_destination_folder}}"
94           - name: git_cred_secret
95             value: "{{inputs.parameters.git_fleet_cred_secret}}"
96           - name: git_volume_name
97             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
98     # ------ end of preparations for transaction
99
100     # ------ Transformations
101     # Disconnect the remote cluster
102     - - name: disconnect-flux-remote-cluster
103         templateRef:
104           name: cluster-management-wft
105           template: disconnect-flux-remote-cluster
106         arguments:
107           parameters:
108           # Volumes with cloned repos
109           - name: fleet_volume_name
110             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
111
112           # Specific parameters
113           - name: cluster_kustomization_name
114             value: "{{inputs.parameters.cluster_kustomization_name}}"
115           - name: mgmt_project_name
116             value: "{{inputs.parameters.mgmt_project_name}}"
117     # ------ end of transformations
118
119     # ------ Commit transaction
120     - - name: push-to-fleet
121         templateRef:
122           name: git-wft
123           template: git-commit-merge-push
124         arguments:
125           parameters:
126           - name: mount_path
127             value: "/fleet"
128           - name: repo_folder
129             value: "{{inputs.parameters.fleet_destination_folder}}"
130           - name: git_cred_secret
131             value: "{{inputs.parameters.git_fleet_cred_secret}}"
132           - name: git_volume_name
133             value: '{{steps.generate-fleet-volume-repo.outputs.parameters.pvc-name}}'
134           - name: commit_message
135             value: "Disconnect imported cluster {{inputs.parameters.cluster_kustomization_name}}"
136           - name: main_branch
137             value: main
138           - name: contrib_branch
139             value: osm_contrib
140           - name: dry_run
141             value: "{{inputs.parameters.dry_run}}"
142 # ------ end of commit transaction