Add description check for spaces around omitempty directive

This commit is contained in:
Paul Morie 2015-11-17 01:51:57 -05:00
parent b7eb2caf5e
commit 1f9d605096

View File

@ -26,6 +26,7 @@ kube::golang::setup_env
# Find binary
genswaggertypedocs=$(kube::util::find-binary "genswaggertypedocs")
gen_swagger_result=0
result=0
find_files() {
@ -53,18 +54,29 @@ else
fi
for file in $versioned_api_files; do
$genswaggertypedocs -v -s "${file}" -f - || result=$?
if [[ "${result}" -ne "0" ]]; then
echo "API file: ${file} is missing: ${result} descriptions"
$genswaggertypedocs -v -s "${file}" -f - || gen_swagger_result=$?
if [[ "${gen_swagger_result}" -ne "0" ]]; then
echo "API file: ${file} is missing: ${gen_swagger_result} descriptions"
result=1
fi
if grep json: "${file}" | grep -v // | grep description: ; then
echo "API file: ${file} should not contain descriptions in struct tags"
result=1
fi
if grep json: "${file}" | grep -Ee ",[[:space:]]+omitempty|omitempty[[:space:]]+" ; then
echo "API file: ${file} should not contain leading or trailing spaces for omitempty directive"
result=1
fi
done
internal_types_files="${KUBE_ROOT}/pkg/api/types.go ${KUBE_ROOT}/pkg/apis/experimental/types.go"
internal_types_files="${KUBE_ROOT}/pkg/api/types.go ${KUBE_ROOT}/pkg/apis/extensions/types.go"
for internal_types_file in $internal_types_files; do
if [[ ! -e $internal_types_file ]]; then
echo "Internal types file ${internal_types_file} does not exist"
result=1
continue
fi
if grep json: "${internal_types_file}" | grep -v // | grep description: ; then
echo "Internal API types should not contain descriptions"
result=1