Merge pull request #17358 from pmorie/omitempty-space

Add description check for spaces around omitempty directive
pull/6/head
Abhi Shah 2015-11-18 14:59:06 -08:00
commit 7d95a4ce05
1 changed files with 16 additions and 4 deletions

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