Skip to content

Commit 78a2f6d

Browse files
authored
feat(generator): clone whole API spec repo on oas download (#235)
needed in the future for the multi-API-version support in our SDKs relates to STACKITSDK-294 and STACKITSDK-297
1 parent d2d2d20 commit 78a2f6d

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

scripts/download-oas.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ if [[ -z ${OAS_API_VERSIONS} ]]; then
2323
OAS_API_VERSIONS="${ROOT_DIR}/api-versions-lock.json"
2424
fi
2525

26+
if [ -d "${ROOT_DIR}/oas" ]; then
27+
echo "OAS folder found. Will be removed"
28+
rm -rf "${ROOT_DIR}/oas"
29+
fi
30+
31+
git clone "${OAS_REPO}" "${ROOT_DIR}/oas" --quiet
32+
# OPTIONAL: Lock to a specific commit
33+
# cd "${ROOT_DIR}/oas"
34+
# git checkout <HASH>
35+
36+
# NOTE: Everything below is needed for the "compatibility layer" logic.
37+
# It can be completely removed once the compatibility layer isn't needed anymore in the SDK.
38+
2639
# Create temp directory to clone OAS repo
2740
work_dir=$(mktemp -d)
2841
if [[ ! ${work_dir} || -d {work_dir} ]]; then
@@ -31,13 +44,7 @@ if [[ ! ${work_dir} || -d {work_dir} ]]; then
3144
fi
3245
trap "rm -rf ${work_dir}" EXIT # Delete temp directory on exit
3346

34-
if [ -d "${ROOT_DIR}/oas" ]; then
35-
echo "OAS folder found. Will be removed"
36-
rm -r "${ROOT_DIR}/oas"
37-
fi
38-
39-
# Move oas to root level
40-
mkdir "${ROOT_DIR}/oas"
47+
mkdir "${ROOT_DIR}/oas/legacy"
4148
cd "${work_dir}"
4249
git clone "${OAS_REPO}" --quiet
4350

@@ -67,11 +74,6 @@ EOF
6774
service_normalized=$(echo "${service_normalized}" | tr '[:upper:]' '[:lower:]') # convert upper case letters to lower case
6875
service_normalized=$(echo "${service_normalized}" | tr -d -c '[:alnum:]') # remove non-alphanumeric characters
6976
echo "$service_normalized=$(git rev-parse HEAD)" >> oas_commits
70-
# To support initial integrations of the IaaS API in an Alpha state, we will temporarily use it to generate an IaaS Alpha SDK module
71-
# This check can be removed once the IaaS API moves all endpoints to Beta
72-
if [[ ${service_normalized} == "iaas" ]]; then
73-
echo "iaasalpha=$(git rev-parse HEAD)" >> oas_commits
74-
fi
7577

7678
cd - >/dev/null
7779

@@ -88,12 +90,6 @@ EOF
8890
version=${version#v}
8991
# Check if version is alpha
9092
if [[ ${version} == *alpha* ]]; then
91-
# To support initial integrations of the IaaS API in an Alpha state, we will temporarily use it to generate an IaaS Alpha SDK module
92-
# This check can be removed once the IaaS API moves all endpoints to Beta
93-
if [[ ${service} == "iaas" ]]; then
94-
mv -f ${dir}/*.json ${ROOT_DIR}/oas/iaasalpha.json
95-
continue
96-
fi
9793
if [[ ${ALLOW_ALPHA} != "true" ]]; then
9894
continue
9995
fi
@@ -135,6 +131,6 @@ EOF
135131
echo "No elegible OAS found for ${service_dir}"
136132
continue
137133
fi
138-
mv -f ${max_version_dir}/*.json ${ROOT_DIR}/oas
134+
mv -f ${max_version_dir}/*.json ${ROOT_DIR}/oas/legacy
139135
done
140-
mv -f ${work_dir}/${OAS_REPO_NAME}/oas_commits ${ROOT_DIR}/oas/oas_commits
136+
mv -f ${work_dir}/${OAS_REPO_NAME}/oas_commits ${ROOT_DIR}/oas/legacy/oas_commits

scripts/generate-sdk/languages/go.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ generate_go_sdk() {
109109
warning=""
110110

111111
# Generate SDK for each service
112-
for service_json in ${ROOT_DIR}/oas/*.json; do
112+
for service_json in ${ROOT_DIR}/oas/legacy/*.json; do
113113
service="${service_json##*/}"
114114
service="${service%.json}"
115115

scripts/generate-sdk/languages/java.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ generate_java_sdk() {
7878
warning=""
7979

8080
# Generate SDK for each service
81-
for service_json in "${ROOT_DIR}"/oas/*.json; do
81+
for service_json in "${ROOT_DIR}"/oas/legacy/*.json; do
8282
service="${service_json##*/}"
8383
service="${service%.json}"
8484

scripts/generate-sdk/languages/python.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ generate_python_sdk() {
8181
warning=""
8282

8383
# Generate SDK for each service
84-
for service_json in ${ROOT_DIR}/oas/*.json; do
84+
for service_json in ${ROOT_DIR}/oas/legacy/*.json; do
8585
service="${service_json##*/}"
8686
service="${service%.json}"
8787

scripts/sdk-create-pr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
127127
echo "old commit: ${old_commit}"
128128
fi
129129
new_commit=""
130-
if [[ -f "${ROOT_DIR}/oas/oas_commits" ]]; then
131-
new_commit=$(grep "${service}=" "${ROOT_DIR}/oas/oas_commits" | cut -d = -f 2)
130+
if [[ -f "${ROOT_DIR}/oas/legacy/oas_commits" ]]; then
131+
new_commit=$(grep "${service}=" "${ROOT_DIR}/oas/legacy/oas_commits" | cut -d = -f 2)
132132
echo "new commit: ${new_commit}"
133133
fi
134134
compare_link=""

0 commit comments

Comments
 (0)