Fix generate-internal-groups.sh for bash < 5.x

The script fails for older versions of bash, because the expansion of
the empty OPENAPI_EXTRA_PACKAGES array fails on older bash versions.

The issue was encountered on 3.2.57 (macos), and 4.2.46-34.el7 (latest
bash on Centos). The issue was not present on 5.0.18 (macos).

This commit patches the issue for older bash versions, by using the
'+' operator to avoid expanding OPENAPI_EXTRA_PACKAGES if it is empty.
This commit is contained in:
erwinvaneyk 2020-10-07 14:23:35 +02:00
parent e99df0e5a7
commit b7d9ff26d1

View File

@ -114,7 +114,7 @@ if [ "${GENS}" = "all" ] || grep -qw "openapi" <<<"${GENS}"; then
echo "Generating OpenAPI definitions for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/openapi"
declare -a OPENAPI_EXTRA_PACKAGES
"${GOPATH}/bin/openapi-gen" \
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}" "${OPENAPI_EXTRA_PACKAGES[@]}")" \
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}" "${OPENAPI_EXTRA_PACKAGES[@]+"${OPENAPI_EXTRA_PACKAGES[@]}"}")" \
--input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/version" \
--output-package "${OUTPUT_PKG}/openapi" \
-O zz_generated.openapi \