...
1#!/bin/bash
2
3if [ ! -f ./_output/tools/bin/yq ]; then
4 mkdir -p ./_output/tools/bin
5 curl -s -f -L https://github.com/mikefarah/yq/releases/download/2.4.0/yq_$(go env GOHOSTOS)_$(go env GOHOSTARCH) -o ./_output/tools/bin/yq
6 chmod +x ./_output/tools/bin/yq
7fi
8
9FAILS=false
10
11for f in $(find . -name "*.yaml" -type f); do
12 grep -qre "kind:\(.*\)CustomResourceDefinition" $f || continue
13 grep -qre "name:\(.*\).openshift.io" $f || continue
14
15 if [[ $(./_output/tools/bin/yq r $f apiVersion) == "apiextensions.k8s.io/v1beta1" ]]; then
16 if [[ $(./_output/tools/bin/yq r $f spec.validation.openAPIV3Schema.properties.metadata.description) != "null" ]]; then
17 echo "Error: cannot have a metadata description in $f"
18 FAILS=true
19 fi
20
21 if [[ $(./_output/tools/bin/yq r $f spec.preserveUnknownFields) != "false" ]]; then
22 echo "Error: pruning not enabled (spec.preserveUnknownFields != false) in $f"
23 FAILS=true
24 fi
25 fi
26
27 if [[ $(./_output/tools/bin/yq r $f metadata.annotations[api-approved.openshift.io]) == "null" ]]; then
28 echo "Error: missing 'api-approved.openshift.io' annotation pointing to openshift/api pull request in $f"
29 FAILS=true
30 fi
31done
32
33if [ "$FAILS" = true ] ; then
34 exit 1
35fi
36
View as plain text