Skip to content

Commit

Permalink
bugfix: docker cannot pass array environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohlool committed Aug 11, 2017
1 parent bd1c420 commit 4d14352
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion openapi/client-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ kubeclient::generator::generate_client() {
--build-arg SWAGGER_CODEGEN_COMMIT="${SWAGGER_CODEGEN_COMMIT}" \
--build-arg GENERATION_XML_FILE="${CLIENT_LANGUAGE}.xml"

# Docker does not support passing arrays, pass the string representation
# of the array instead (space separated)
CLEANUP_DIRS_STRING="${CLEANUP_DIRS[@]}"

echo "--- Running generator inside container..."
docker run \
-e CLEANUP_DIRS \
-e CLEANUP_DIRS="${CLEANUP_DIRS_STRING}" \
-e KUBERNETES_BRANCH \
-e CLIENT_VERSION \
-e PACKAGE_NAME \
Expand Down
9 changes: 5 additions & 4 deletions openapi/generate_client_in_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail

# Generates client.
# Required env vars:
# CLEANUP_DIRS: List of directories to cleanup before generation for this language
# CLEANUP_DIRS: List of directories (string separated by space) to cleanup before generation for this language
# KUBERNETES_BRANCH: Kubernetes branch name to get the swagger spec from
# CLIENT_VERSION: Client version. Will be used in the comment sections of the generated code
# PACKAGE_NAME: Name of the client package.
Expand Down Expand Up @@ -76,14 +76,15 @@ echo "--- Downloading and pre-processing OpenAPI spec"
python "${SCRIPT_ROOT}/preprocess_spec.py" "${KUBERNETES_BRANCH}" "${output_dir}/swagger.json"

echo "--- Cleaning up previously generated folders"
for i in ${CLEANUP_DIRS[@]}; do
for i in ${CLEANUP_DIRS}; do
echo "--- Cleaning up ${output_dir}/${i}"
rm -rf "${output_dir}/${i}"
done

echo "--- Generating client ..."
mvn -f "${SCRIPT_ROOT}/generation_params.xml" clean generate-sources -Dgenerator.spec.path="${output_dir}/swagger.json" -Dgenerator.output.path="${output_dir}" -D=generator.client.version="${CLIENT_VERSION}" -D=generator.package.name="${PACKAGE_NAME}" -D=swagger-codegen-version="${PLUGIN_VERSION}"

echo "" >> "${output_dir}/.swagger-codegen/VERSION"
echo "commit: ${SWAGGER_CODEGEN_COMMIT}" >> "${output_dir}/.swagger-codegen/VERSION"
mkdir -p "${output_dir}/.swagger-codegen"
echo "${SWAGGER_CODEGEN_COMMIT}" > "${output_dir}/.swagger-codegen/COMMIT"

echo "---Done."

0 comments on commit 4d14352

Please sign in to comment.