Skip to content

Commit 46e6c61

Browse files
update gen-sdk.sh to generate sdk using docker container (kubernetes-sigs#681)
* update gen-sdk.sh to generate sdk using docker container * clean up some of the code apt install * added docker install so gen-sdk script can use docker * update bash script, doing some quick local testing * finish hooking up volumes and the sdk generation * adding selection to remove installsation of docker * ran locally with docker and podman installed * Revert "ran locally with docker and podman installed" This reverts commit cdd94de. * keep the update for gen-sdk.sh * removed docker install to make similar to the python sdk install * added podman support * removed podman for testing * clean up podman left overs * update the pathing for k8 test image
1 parent a4512dd commit 46e6c61

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

hack/python-sdk/gen-sdk.sh

+12-16
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ set -x
2323

2424
repo_root="$(pwd)"
2525

26-
SWAGGER_JAR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar"
27-
SWAGGER_CODEGEN_JAR="${repo_root}/hack/python-sdk/openapi-generator-cli.jar"
2826
SWAGGER_CODEGEN_CONF="${repo_root}/hack/python-sdk/swagger_config.json"
2927
SDK_OUTPUT_PATH="${repo_root}/sdk/python"
3028
VERSION=0.1.4
@@ -37,31 +35,29 @@ fi
3735
echo "Generating OpenAPI specification ..."
3836
echo "./hack/update-codegen.sh already help us generate openapi specs ..."
3937

40-
if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then
41-
echo "Downloading the swagger-codegen JAR package ..."
42-
wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL}
43-
fi
44-
45-
if [ -z `which java` ]; then
46-
apt-get update -y
47-
# TODO: update this fallback (remove it) when openjdk-11 completely deprecated
48-
echo "Installing OpenJDK 11 with fallback to OpenJDK 17"
49-
apt-get install -y openjdk-11-jdk || apt-get install -y openjdk-17-jdk
50-
fi
51-
5238
echo "Generating swagger file ..."
5339
go run "${repo_root}"/hack/swagger/main.go ${VERSION} >"${SWAGGER_CODEGEN_FILE}"
5440

5541
echo "Removing previously generated files ..."
5642
rm -rf "${SDK_OUTPUT_PATH}"/docs/V1*.md "${SDK_OUTPUT_PATH}"/jobset/models "${SDK_OUTPUT_PATH}"/test/test_*.py
5743

5844
echo "Generating Python SDK for JobSet..."
59-
java -jar "${SWAGGER_CODEGEN_JAR}" generate -i ${SWAGGER_CODEGEN_FILE} -g python -o "${SDK_OUTPUT_PATH}" -c "${SWAGGER_CODEGEN_CONF}"
45+
46+
# Defaults the container engine to docker
47+
CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
48+
49+
# Install the sdk using docker, using the user that is running the container engine so that files can still be removed
50+
${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \
51+
-v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \
52+
-i /local/hack/python-sdk/swagger.json \
53+
-g python \
54+
-o /local/sdk/python \
55+
-c local/hack/python-sdk/swagger_config.json
6056

6157
echo "Running post-generation script ..."
6258
"${repo_root}"/hack/python-sdk/post_gen.py
6359

6460
echo "JobSet Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/."
6561

6662
# Remove setup.py
67-
rm ${SDK_OUTPUT_PATH}/setup.py
63+
rm "${SDK_OUTPUT_PATH}"/setup.py

0 commit comments

Comments
 (0)