mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Add description check for spaces around omitempty directive
This commit is contained in:
parent
b7eb2caf5e
commit
1f9d605096
@ -26,6 +26,7 @@ kube::golang::setup_env
|
|||||||
# Find binary
|
# Find binary
|
||||||
genswaggertypedocs=$(kube::util::find-binary "genswaggertypedocs")
|
genswaggertypedocs=$(kube::util::find-binary "genswaggertypedocs")
|
||||||
|
|
||||||
|
gen_swagger_result=0
|
||||||
result=0
|
result=0
|
||||||
|
|
||||||
find_files() {
|
find_files() {
|
||||||
@ -53,18 +54,29 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for file in $versioned_api_files; do
|
for file in $versioned_api_files; do
|
||||||
$genswaggertypedocs -v -s "${file}" -f - || result=$?
|
$genswaggertypedocs -v -s "${file}" -f - || gen_swagger_result=$?
|
||||||
if [[ "${result}" -ne "0" ]]; then
|
if [[ "${gen_swagger_result}" -ne "0" ]]; then
|
||||||
echo "API file: ${file} is missing: ${result} descriptions"
|
echo "API file: ${file} is missing: ${gen_swagger_result} descriptions"
|
||||||
|
result=1
|
||||||
fi
|
fi
|
||||||
if grep json: "${file}" | grep -v // | grep description: ; then
|
if grep json: "${file}" | grep -v // | grep description: ; then
|
||||||
echo "API file: ${file} should not contain descriptions in struct tags"
|
echo "API file: ${file} should not contain descriptions in struct tags"
|
||||||
result=1
|
result=1
|
||||||
fi
|
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
|
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
|
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
|
if grep json: "${internal_types_file}" | grep -v // | grep description: ; then
|
||||||
echo "Internal API types should not contain descriptions"
|
echo "Internal API types should not contain descriptions"
|
||||||
result=1
|
result=1
|
||||||
|
Loading…
Reference in New Issue
Block a user