diff --git a/scripts/download-oas.sh b/scripts/download-oas.sh index e2c6f9e..a1c1c9a 100755 --- a/scripts/download-oas.sh +++ b/scripts/download-oas.sh @@ -20,7 +20,7 @@ fi # Create temp directory to clone OAS repo work_dir=$(mktemp -d) if [[ ! ${work_dir} || -d {work_dir} ]]; then - echo "Unable to create temporary directory" + echo "! Unable to create temporary directory" exit 1 fi trap "rm -rf ${work_dir}" EXIT # Delete temp directory on exit @@ -55,8 +55,8 @@ for service_dir in ${work_dir}/${OAS_REPO_NAME}/services/*; do if [[ ${version} == *alpha* ]]; then # To support initial integrations of the IaaS API in an Alpha state, we will temporarily use it to generate an IaaS Alpha SDK module # This check can be removed once the IaaS API moves all endpoints to Beta - if [[ ${service} == "iaas" ]]; then - mv -f ${dir}/*.json ${ROOT_DIR}/oas/iaasalpha.json + if [[ ${service} == "iaas" ]]; then + mv -f ${dir}/*.json ${ROOT_DIR}/oas/iaasalpha.json fi if [[ ${ALLOW_ALPHA} != "true" ]]; then continue diff --git a/scripts/generate-sdk/languages/go.sh b/scripts/generate-sdk/languages/go.sh index cd8e08d..c13e0f7 100644 --- a/scripts/generate-sdk/languages/go.sh +++ b/scripts/generate-sdk/languages/go.sh @@ -62,7 +62,7 @@ generate_go_sdk() { if type -p go >/dev/null; then : else - echo "Go not installed, unable to proceed." + echo "! Go not installed, unable to proceed." exit 1 fi @@ -80,7 +80,7 @@ generate_go_sdk() { # Backup of the current state of the SDK services dir (services/) sdk_services_backup_dir=$(mktemp -d) if [[ ! ${sdk_services_backup_dir} || -d {sdk_services_backup_dir} ]]; then - echo "Unable to create temporary directory" + echo "! Unable to create temporary directory" exit 1 fi cleanup() { @@ -128,7 +128,7 @@ generate_go_sdk() { exit 1 fi - echo -e "\nGenerating \"${service}\" service..." + echo -e "\n>> Generating \"${service}\" service..." cd ${ROOT_DIR} GO_POST_PROCESS_FILE="gofmt -w" \ diff --git a/scripts/generate-sdk/languages/python.sh b/scripts/generate-sdk/languages/python.sh index 3164855..52d45c5 100644 --- a/scripts/generate-sdk/languages/python.sh +++ b/scripts/generate-sdk/languages/python.sh @@ -24,12 +24,12 @@ generate_python_sdk() { # Check required parameters if [[ -z ${GIT_HOST} ]]; then - echo "GIT_HOST not specified." + echo "! GIT_HOST not specified." exit 1 fi if [[ -z ${GIT_USER_ID} ]]; then - echo "GIT_USER_ID id not specified." + echo "! GIT_USER_ID id not specified." exit 1 fi @@ -46,7 +46,7 @@ generate_python_sdk() { # Prepare folders if [[ ! -d $SERVICES_FOLDER ]]; then - mkdir -p "$SERVICES_FOLDER" + mkdir -p "$SERVICES_FOLDER" fi # Clone SDK repo @@ -63,7 +63,7 @@ generate_python_sdk() { # Backup of the current state of the SDK services dir (services/) sdk_services_backup_dir=$(mktemp -d) if [[ ! ${sdk_services_backup_dir} || -d {sdk_services_backup_dir} ]]; then - echo "Unable to create temporary directory" + echo "! Unable to create temporary directory" exit 1 fi cleanup() { @@ -75,7 +75,7 @@ generate_python_sdk() { trap cleanup EXIT # Remove old contents of services dir (services/) - rm -rf ${SERVICES_FOLDER} + rm -rf ${SERVICES_FOLDER} # Generate SDK for each service for service_json in ${ROOT_DIR}/oas/*.json; do @@ -89,7 +89,7 @@ generate_python_sdk() { service=$(echo "${service}" | tr '[:upper:]' '[:lower:]') # convert upper case letters to lower case service=$(echo "${service}" | tr -d -c '[:alnum:]') # remove non-alphanumeric characters - echo "Generating \"${service}\" service..." + echo ">> Generating \"${service}\" service..." cd ${ROOT_DIR} mkdir -p "${SERVICES_FOLDER}/${service}/" @@ -113,11 +113,11 @@ generate_python_sdk() { rm -r "${SERVICES_FOLDER}/${service}/.openapi-generator/" rm "${SERVICES_FOLDER}/${service}/stackit/__init__.py" rm "${SERVICES_FOLDER}/${service}/.github/workflows/python.yml" - + # Create source layout mkdir "${SERVICES_FOLDER}/${service}/src" mv "${SERVICES_FOLDER}/${service}/stackit/" "${SERVICES_FOLDER}/${service}/src/" - + # If the service has a wait package files, move them inside the service folder if [ -d ${sdk_services_backup_dir}/${service}/src/wait ]; then echo "Found ${service} \"wait\" package" @@ -165,6 +165,6 @@ generate_python_sdk() { isort . autoimport --ignore-init-modules . black . - + done } diff --git a/scripts/project.sh b/scripts/project.sh index 8b3faa7..a29840a 100755 --- a/scripts/project.sh +++ b/scripts/project.sh @@ -27,8 +27,8 @@ elif [ "$action" = "tools" ]; then elif [ "${LANGUAGE}" == "python" ]; then pip install black==24.8.0 isort~=5.13.2 autoimport~=1.6.1 else - echo "Invalid language: `$LANGUAGE`, please use $0 help for help" + echo "! Invalid language: $($LANGUAGE), please use $0 help for help" fi else - echo "Invalid action: '$action', please use $0 help for help" + echo "! Invalid action: '$action', please use $0 help for help" fi diff --git a/scripts/sdk-create-pr.sh b/scripts/sdk-create-pr.sh index fd24cb3..8696503 100755 --- a/scripts/sdk-create-pr.sh +++ b/scripts/sdk-create-pr.sh @@ -80,7 +80,6 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do service_changes=$(git status --porcelain "services/$service") if [[ -n "$service_changes" ]]; then - echo "Committing changes for $service" if [[ "$BRANCH_PREFIX" != "main" ]]; then git switch main # This is needed to create a new branch for the service without including the previously committed files branch="$BRANCH_PREFIX/$service" @@ -99,17 +98,21 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do fi if [[ "$branch" != "main" ]]; then + echo ">> Creating PR for $service" + git commit -m "Generate $service" git push origin "$branch" gh pr create --title "Generator: Update SDK /services/$service" --body "$COMMIT_INFO" --head "$branch" --base "main" else + echo ">> Pushing changes for $service service..." + # If lint or test fails for a service, we skip it and continue to the next one make lint skip-non-generated-files=true service=$service || { - echo "Linting failed for service: $service" + echo "! Linting failed for $service" continue } make test skip-non-generated-files=true service=$service || { - echo "Testing failed for service: $service" + echo "! Testing failed for $service" continue }