forked from rook/rook
Finally! We can now stop editing manually our crds definition. Simply run `make crds-gen`. These two files: * `cluster/examples/kubernetes/ceph/crds.yaml` * `cluster/charts/rook-ceph/templates/resources.yaml` will be autogenerated for us. We rely on the controller-gen tool, it reads our API definitions from `pkg/apis/` and produces the CRD files accordingly. It uses "markers" to add extra yaml fields to the CRD, for instance we have a lot fields with: ``` nullable: true x-kubernetes-preserve-unknown-fields: true ``` The corresponding API type markers are: ``` // +kubebuilder:pruning:PreserveUnknownFields // +nullable ``` For more API convention see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required and for the markers see: https://book.kubebuilder.io/reference/markers/crd-validation.html Signed-off-by: Sébastien Han <seb@redhat.com>
44 lines
764 B
Bash
Executable File
44 lines
764 B
Bash
Executable File
#!/bin/bash
|
|
set -ex
|
|
|
|
#############
|
|
# VARIABLES #
|
|
#############
|
|
CODEGEN_ERR="found codegen files! please run 'make codegen' and update your PR"
|
|
MOD_ERR="changes found by mod.check. You may need to run make clean"
|
|
CRD_ERR="changes found by 'make crds-gen'. please run 'make crds-gen' locally and update your PR"
|
|
|
|
#############
|
|
# FUNCTIONS #
|
|
#############
|
|
function validate(){
|
|
git=$(git status --porcelain)
|
|
for file in $git; do
|
|
if [ -n "$file" ]; then
|
|
echo "$1"
|
|
echo "$git"
|
|
git diff
|
|
exit 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
########
|
|
# MAIN #
|
|
########
|
|
case "$1" in
|
|
codegen)
|
|
validate "$CODEGEN_ERR"
|
|
;;
|
|
modcheck)
|
|
validate "$MOD_ERR"
|
|
;;
|
|
crd)
|
|
validate "$CRD_ERR"
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {codegen|modcheck|crd}"
|
|
exit 1
|
|
esac
|
|
|