Files
kustomize/functions/examples/fn-framework-application/pkg/exampleapp/v1alpha1/crd_gen.sh
2023-04-13 16:57:50 -04:00

22 lines
863 B
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
# This generates a useful starting point for a CRD that can be used for validation.
echo " - Generating CRD"
controller-gen crd paths=./... output:crd:dir=.
# controller-gen does not currently support "additionalProperties: false".
# This hack adds it manually to all properties sections of the schema.
echo " - Adding additionalProperties: false to all properties sections"
if [[ "$OSTYPE" == linux* ]]; then
# Linux (GNU sed) expression
sed -i "s/\(^[[:space:]]*\)properties:/\1additionalProperties: false\n\1properties:/g" ./platform.example.com_exampleapps.yaml
elif [[ "$OSTYPE" == darwin* ]]; then
# macOS (BSD sed) expression
sed -i "" "s/\(^[[:space:]]*\)properties:/\1additionalProperties: false\n\1properties:/g" ./platform.example.com_exampleapps.yaml
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi