Skip to content
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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ROOT_DIR ?= $(shell git rev-parse --show-toplevel)
SCRIPTS_BASE ?= $(ROOT_DIR)/scripts
API_VERSION ?= $(shell cat api_version|grep -v '^\#'|head -n 1)
SDK_BRANCH ?= main

# SETUP AND TOOL INITIALIZATION TASKS
project-help:
Expand All @@ -10,7 +12,8 @@ project-tools:

# GENERATE
download-oas:
@$(SCRIPTS_BASE)/download-oas.sh "$(OAS_REPO_NAME)" "$(OAS_REPO)" "$(ALLOW_ALPHA)"
@$(SCRIPTS_BASE)/download-oas.sh "$(OAS_REPO_NAME)" "$(OAS_REPO)" "$(ALLOW_ALPHA)" "$(API_VERSION)"

generate-sdk:
@$(SCRIPTS_BASE)/generate-sdk/generate-sdk.sh "$(GIT_HOST)" "$(GIT_USER_ID)" "$(GIT_REPO_ID)" "$(SDK_REPO_URL)" "$(LANGUAGE)"
@$(SCRIPTS_BASE)/generate-sdk/generate-sdk.sh "$(GIT_HOST)" "$(GIT_USER_ID)" "$(GIT_REPO_ID)" "$(SDK_REPO_URL)" "$(LANGUAGE)" "$(SDK_BRANCH)"

3 changes: 3 additions & 0 deletions api_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 2e3768b7b65237391fc587eddd559451f2b183a6
# comments are allowed!
main
11 changes: 11 additions & 0 deletions scripts/download-oas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
OAS_REPO_NAME=$1
OAS_REPO=$2
ALLOW_ALPHA=$3
OAS_API_VERSION=$4

if [[ -z ${OAS_REPO_NAME} ]]; then
echo "Repo name is empty, default public OAS repo name will be used."
Expand All @@ -17,6 +18,11 @@ if [[ ! ${OAS_REPO} || -d ${OAS_REPO} ]]; then
OAS_REPO="https://github.com/stackitcloud/${OAS_REPO_NAME}.git"
fi

if [[ -z ${OAS_API_VERSION} ]]; then
echo "No API version passed, main branch will be used"
OAS_API_VERSION="main"
fi

# Create temp directory to clone OAS repo
work_dir=$(mktemp -d)
if [[ ! ${work_dir} || -d {work_dir} ]]; then
Expand All @@ -35,6 +41,11 @@ mkdir ${ROOT_DIR}/oas
cd ${work_dir}
git clone ${OAS_REPO} --quiet

echo "Using api version ${OAS_API_VERSION}"
cd ${OAS_REPO_NAME}
git checkout --quiet ${OAS_API_VERSION}
cd -

for service_dir in ${work_dir}/${OAS_REPO_NAME}/services/*; do
max_version_dir=""
max_version=-1
Expand Down
8 changes: 7 additions & 1 deletion scripts/generate-sdk/generate-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ GIT_USER_ID=$2
GIT_REPO_ID=$3
SDK_REPO_URL=$4
LANGUAGE=$5
SDK_BRANCH=$6

# Global variables
ROOT_DIR=$(git rev-parse --show-toplevel)
Expand All @@ -32,6 +33,11 @@ if [[ -z ${LANGUAGE} ]]; then
LANGUAGE="go"
fi

if [[ -z ${SDK_BRANCH} ]]; then
echo "SDK_BRANCH not specified, main branch will be used."
SDK_BRANCH=main
fi

# Check dependencies
if type -p java >/dev/null; then
:
Expand Down Expand Up @@ -78,7 +84,7 @@ go)

source ${LANGUAGE_GENERATORS_FOLDER_PATH}/${LANGUAGE}.sh
# Usage: generate_go_sdk GENERATOR_PATH GIT_HOST GIT_USER_ID [GIT_REPO_ID] [SDK_REPO_URL]
generate_go_sdk ${jar_path} ${GIT_HOST} ${GIT_USER_ID} ${GIT_REPO_ID} ${SDK_REPO_URL}
generate_go_sdk "${jar_path}" "${GIT_HOST}" "${GIT_USER_ID}" "${GIT_REPO_ID}" "${SDK_REPO_URL}" "${SDK_BRANCH}"
;;
python)
echo -e "\n>> Generating the Python SDK..."
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate-sdk/languages/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ generate_go_sdk() {
# Optional parameters
local GIT_REPO_ID=$4
local SDK_REPO_URL=$5
local SDK_BRANCH=$6

# Check required parameters
if [[ -z ${GIT_HOST} ]]; then
Expand Down Expand Up @@ -75,6 +76,7 @@ generate_go_sdk() {

# Install SDK project tools
cd ${SDK_REPO_LOCAL_PATH}
git checkout ${SDK_BRANCH}
make project-tools

# Backup of the current state of the SDK services dir (services/)
Expand Down
Loading