2022-07-27 17:28:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
BUNDLE_DIR="${1}"
|
|
|
|
CRD_DIR="${2}"
|
|
|
|
BUNDLE_YAML="${BUNDLE_DIR}/bundle.yaml"
|
|
|
|
|
|
|
|
cd "${SCRIPT_DIR}"/../
|
|
|
|
|
2023-08-02 19:42:03 +00:00
|
|
|
go run sigs.k8s.io/controller-tools/cmd/controller-gen \
|
2022-07-27 17:28:59 +00:00
|
|
|
object:headerFile="hack/boilerplate.go.txt" \
|
2022-10-06 17:14:13 +00:00
|
|
|
paths="./apis/..."
|
2022-07-27 17:28:59 +00:00
|
|
|
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd \
|
2022-10-06 17:14:13 +00:00
|
|
|
paths="./apis/..." \
|
2022-07-27 17:28:59 +00:00
|
|
|
output:crd:artifacts:config="${CRD_DIR}/bases"
|
|
|
|
|
2024-05-06 22:50:37 +00:00
|
|
|
## Update resources list from kustomization.yaml
|
|
|
|
ls "${CRD_DIR}"/bases | grep -v "kustomization.yaml" | jq -R -s -c 'split("\n")[:-1]' | yq -p=json - > kustomize-files.yaml
|
|
|
|
yq -i '.resources = (load("kustomize-files.yaml"))' "${CRD_DIR}"/bases/kustomization.yaml
|
|
|
|
rm kustomize-files.yaml
|
|
|
|
|
2022-07-27 17:28:59 +00:00
|
|
|
# Remove extra header lines in generated CRDs
|
|
|
|
# This is needed for building the helm chart
|
|
|
|
for f in "${CRD_DIR}"/bases/*.yaml; do
|
|
|
|
if [[ $f == *kustomization.yaml ]];
|
|
|
|
then
|
|
|
|
continue;
|
|
|
|
fi;
|
|
|
|
tail -n +2 < "$f" > "$f.bkp"
|
|
|
|
cp "$f.bkp" "$f"
|
|
|
|
rm "$f.bkp"
|
|
|
|
done
|
|
|
|
|
|
|
|
shopt -s extglob
|
|
|
|
yq e \
|
|
|
|
'.spec.conversion.strategy = "Webhook" | .spec.conversion.webhook.conversionReviewVersions = ["v1"] | .spec.conversion.webhook.clientConfig.service.name = "kubernetes" | .spec.conversion.webhook.clientConfig.service.namespace = "default" | .spec.conversion.webhook.clientConfig.service.path = "/convert"' \
|
|
|
|
"${CRD_DIR}"/bases/!(kustomization).yaml > "${BUNDLE_YAML}"
|