-
Notifications
You must be signed in to change notification settings - Fork 472
/
update-crds.sh
executable file
·64 lines (46 loc) · 1.61 KB
/
update-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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
GOPATH=$(go env GOPATH)
controllergen="$GOPATH/bin/controller-gen"
PKG=sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0
if [ ! -e "$controllergen" ]; then
echo "Getting $PKG"
go install $PKG
fi
"$controllergen" \
crd \
schemapatch:manifests=./artifacts/crds \
paths=./pkg/apis/... \
output:dir=./artifacts/crds
# Prevent CRDs from being removed via helm uninstall
# Only annotate CRDs which are held in templates, but not the ones in the crds/ folder
ANNOTATE_CRDS=("openfaas.com_profiles.yaml" "openfaas.com_functioningresses.yaml" "openfaas.com_functions.yaml")
for f in ./artifacts/crds/*.yaml; do \
annotate=false
for i in "${ANNOTATE_CRDS[@]}"; do
if [ "$i" == "$(basename $f)" ]; then
annotate=true
break
fi
done
echo "Updating: $f"
tmp_file=$(mktemp)
if [ "$annotate" == true ]; then
kubectl annotate --overwrite -f $f --local=true -o yaml helm.sh/resource-policy=keep > tmp_file
mv tmp_file $f
fi
kubectl label --overwrite -f $f --local=true -o yaml app.kubernetes.io/name=openfaas > tmp_file
mv tmp_file $f
rm -f tmp_file
done
echo "# Combined OpenFaaS CRDs " > ./artifacts/crds/crds.yaml
for f in ./artifacts/crds/*.yaml; do \
if [ $f != "./artifacts/crds/crds.yaml" ]; then
echo "---" >> ./artifacts/crds/crds.yaml
cat $f >> ./artifacts/crds/crds.yaml
echo "" >> ./artifacts/crds/crds.yaml
fi
done
echo "Wrote combined CRDs to ./chart/openfaas/artifacts/crds.yaml"
cp ./artifacts/crds/crds.yaml ./chart/openfaas/artifacts/
echo "Copied IAM CRDs to ./chart/openfaas/crds/"
cp ./artifacts/crds/iam.*.yaml ./chart/openfaas/crds/