Skip to content
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

Add jar/zip support #2280

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN set -eux; \
sudo \
curl \
unzip \
grep \
; \
rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ file_upload_endpoint="$FILE_UPLOAD_CONTAINER_URL/$FILE_UPLOAD_BLOB_NAME"

temp_app_source_dir="/tmp/appsource"
temp_app_source_path="$temp_app_source_dir/$FILE_UPLOAD_BLOB_NAME"
temp_app_header_path="$temp_app_source_dir/header.txt"
mkdir $temp_app_source_dir

# List all the environment variables and filter the environment variable with prefix "ACA_CLOUD_BUILD_USER_ENV_", then write them to folder "/platform/env",
Expand All @@ -28,18 +29,35 @@ if [ -n "$CORRELATION_ID" ]; then
echo "$CORRELATION_ID" > "$build_env_dir/CORRELATION_ID"
fi

while [[ ! -f "$temp_app_source_path" || ! "$(file $temp_app_source_path)" =~ "compressed data" ]]
content_type=""
while [[ ! -f "$temp_app_source_path" ||
! "$(file $temp_app_source_path)" =~ "compressed data" &&
! $content_type =~ "application/java-archive" &&
! $content_type =~ "application/gzip" &&
! $content_type =~ "application/zip" ]]
do
echo "Waiting for app source to be uploaded. Please upload the app source to the endpoint specified in the Build resource's 'uploadEndpoint' property."
curl -H "$auth_header" -H "$version_header" -H "$date_header" -X GET "$file_upload_endpoint" -o "$temp_app_source_path" -s
curl -H "$auth_header" -H "$version_header" -H "$date_header" -X GET "$file_upload_endpoint" -o "$temp_app_source_path" -D "$temp_app_header_path" -s
sleep 5

if [[ -f "$temp_app_header_path" ]]; then
content_type=$(grep -i Content-Type "$temp_app_header_path" | cut -d ' ' -f2)
else
echo ""$temp_app_header_path" not found"
fi
done

# Extract app code to CNB_APP_DIR directory.
echo "Found app source at '$temp_app_source_path'. Extracting to $CNB_APP_DIR"
echo "Found app source at '$temp_app_source_path' with format '$content_type'. Extracting to $CNB_APP_DIR"
mkdir -p $CNB_APP_DIR
cd $CNB_APP_DIR
tar -xzf "$temp_app_source_path"

if [[ $content_type =~ "application/zip" || $content_type =~ "java-archive" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content type mistmatch between here and application/java-archive above

unzip -qq "$temp_app_source_path"
else
# Keep compatibility with old logic
tar -xzf "$temp_app_source_path"
fi

fileCount=$(ls | wc -l)
if [ "$fileCount" = "1" ]; then
Expand Down