Skip to content

ci: Generator fix #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ ENV="${2-prod}"

OPENAPI_SPEC=""
if [[ "$API" == "isp" ]]; then
OPENAPI_SPEC="http://api.istreamplanet.com/openapi.json"
OPENAPI_SPEC="https://api.istreamplanet.com/openapi.json"
if [[ $ENV == "stage" ]]; then
OPENAPI_SPEC="http://stage.api.istreamplanet.com/openapi.json"
OPENAPI_SPEC="https://stage.api.istreamplanet.com/openapi.json"
fi
elif [[ "$API" == "isp-slate" ]]; then
OPENAPI_SPEC="http://api.istreamplanet.com/docs/slates/openapi.json"
OPENAPI_SPEC="https://api.istreamplanet.com/docs/slates/openapi.json"
if [[ $ENV == "stage" ]]; then
OPENAPI_SPEC="http://stage.api.istreamplanet.com/docs/slates/openapi.json"
OPENAPI_SPEC="https://stage.api.istreamplanet.com/docs/slates/openapi.json"
fi
elif [[ "$API" == "isp-lifecycle" ]]; then
OPENAPI_SPEC="https://api.istreamplanet.com/state/openapi-3.0.json"
if [[ $ENV == "stage" ]]; then
OPENAPI_SPEC="http://stage.api.istreamplanet.com/state/openapi-3.0.json"
OPENAPI_SPEC="https://stage.api.istreamplanet.com/state/openapi-3.0.json"
fi
else
>&2 echo "Unrecognized api $API. Valid options are: isp, isp-slate, isp-lifecycle"
Expand All @@ -31,6 +31,19 @@ echo -e "Generating ${API} SDK against ${ENV} (${OPENAPI_SPEC})\n"

SCRIPT_DIR=${PWD}

mkdir -p "$SCRIPT_DIR/spec"
SPEC_FILE="spec/$API.yaml"

echo "Writing $OPENAPI_SPEC to $SPEC_FILE"
curl -s "$OPENAPI_SPEC" | yq -P -o=yaml '.' > "$SCRIPT_DIR/$SPEC_FILE"

if [[ "$API" == "isp" ]]; then
yq -i '.info.version = "0.0.0"' "$SCRIPT_DIR/$SPEC_FILE"
else
yq -i '.info.version = "1.0.0"' "$SCRIPT_DIR/$SPEC_FILE"
fi


# Recreate directory to ensure clean build
rm -rf "${API}"
mkdir "${API}"
Expand All @@ -46,7 +59,7 @@ docker run --rm \
-v ${SCRIPT_DIR}:/go-sdk \
"${GENERATOR_IMAGE}" generate \
-g go -c "go-sdk/.generator.yaml" \
-i "${OPENAPI_SPEC}" \
-i "go-sdk/${SPEC_FILE}" \
-o go-sdk/${API}

# Logicless templates are dumping extra quotes around enum values, so we've
Expand All @@ -65,3 +78,7 @@ sed -i.bak -E 's,"github.com/istreamlabs/go-sdk/isp","github.com/istreamlabs/go-

# Cleanup all sed backups
find . -name '*.bak' -delete

echo ""
echo "git status -s"
git status -s
Loading