generated from giantswarm/template-app
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmove-crds.sh
executable file
·32 lines (26 loc) · 1.03 KB
/
move-crds.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# Exit on error.
set -o errexit -o nounset -o pipefail
#
# Moves CRDs from the chart's templates to their component's bases.
#
# Get repository path.
repository="$(realpath "$(dirname "${0}")/..")"
# Iterate components.
# Core is last as it has no prefix and matches all CRDs.
for component in "bootstrap" "controlplane" "core"
do
# Get component prefix.
[ "${component}" != "core" ] && prefix="${component}." || prefix=""
# Remove existing CRDs.
rm -f "${repository}/helm/cluster-api/files/${component}/bases/"*".yaml"
# Iterate generated CRDs.
for crd_path in "${repository}/helm/cluster-api/templates/apiextensions.k8s.io_v1_customresourcedefinition_"*".${prefix}cluster.x-k8s.io.yaml"
do
# Get & shorten CRD file name.
crd_file="$(basename "${crd_path}")"
crd_file="${crd_file#apiextensions.k8s.io_v1_customresourcedefinition_}"
# Move generated CRD.
mv "${crd_path}" "${repository}/helm/cluster-api/files/${component}/bases/${crd_file}"
done
done