Skip to content

Commit 9144184

Browse files
authored
chore: auto formatted publish-layer.sh (#2173)
1 parent 82d2305 commit 9144184

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

packages/aws-lambda/layer/bin/publish-layer.sh

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@ if [[ -z $AWS_ACCESS_KEY_ID ]] || [[ -z $AWS_SECRET_ACCESS_KEY ]]; then
9797
printf "If not, the AWS CLI commands will fail.\n"
9898
fi
9999

100-
101100
# The us-gov-* regions are only available to US government agencies, U.S. government etc. The regions have not been (and
102101
# maybe cannot be) enabled for our AWS account. We currently do not publish Lambda layers to these regions.
103102
SKIPPED_REGIONS=$'us-gov-east-1\nus-gov-west-1'
104103

105-
106-
107104
if [[ -z $REGIONS ]]; then
108105
printf "\nstep 1/9: Fetching AWS regions\n"
109106
REGIONS=$(aws ssm get-parameters-by-path --path /aws/service/global-infrastructure/services/lambda/regions --output text --query "Parameters[].Value" | tr '\t' '\n' | sort)
@@ -125,7 +122,7 @@ while IFS= read -r region; do
125122
else
126123
REGIONS_OTHERS+=("$region")
127124
fi
128-
done <<< "$REGIONS"
125+
done <<<"$REGIONS"
129126

130127
if [[ "$PUBLISH_TO_CHINA_REGIONS" == "true" ]]; then
131128
REGIONS=("${REGIONS_CN[@]}")
@@ -152,9 +149,12 @@ if [[ -z $NO_PROMPT ]]; then
152149
while true; do
153150
read -p "Do you wish to continue (yes or no)? " yn
154151
case $yn in
155-
[Yy]* ) echo "Let's go!"; break;;
156-
[Nn]* ) exit 1;;
157-
* ) echo "Please answer yes or no.";;
152+
[Yy]*)
153+
echo "Let's go!"
154+
break
155+
;;
156+
[Nn]*) exit 1 ;;
157+
*) echo "Please answer yes or no." ;;
158158
esac
159159
done
160160
fi
@@ -196,15 +196,15 @@ rm -rf $ZIP_NAME
196196
rm -rf $TMP_ZIP_DIR
197197
LAYER_WORKDIR=$TMP_ZIP_DIR/nodejs
198198
mkdir -p $LAYER_WORKDIR
199-
pushd $LAYER_WORKDIR > /dev/null
199+
pushd $LAYER_WORKDIR >/dev/null
200200

201201
# convert relative workdir path into absolute path
202202
LAYER_WORKDIR=$(pwd)
203203
echo Will build the layer in working directory: $LAYER_WORKDIR
204204

205205
# We need a dummy package.json file, otherwise npm would think we want to install @instana/aws-lambda into
206206
# packages/aws-lambda/node_modules.
207-
cat <<EOF >> package.json
207+
cat <<EOF >>package.json
208208
{
209209
"private":true
210210
}
@@ -225,7 +225,7 @@ if [[ $BUILD_LAYER_WITH == local ]]; then
225225
echo "step 3/9: building local(!) packages for experimental layer"
226226

227227
# Move up to packages directory
228-
pushd ../../../.. > /dev/null
228+
pushd ../../../.. >/dev/null
229229

230230
echo "Building local tar.gz for @instana/core."
231231
cd core
@@ -244,9 +244,9 @@ if [[ $BUILD_LAYER_WITH == local ]]; then
244244

245245
if [[ -n $REBUILD_LAMBDA_EXTENSION ]]; then
246246
echo "Rebuilding Lambda extension from local sources for @instana/aws-lambda."
247-
pushd ../../../lambda-extension > /dev/null
247+
pushd ../../../lambda-extension >/dev/null
248248
make build
249-
popd > /dev/null
249+
popd >/dev/null
250250
cp ../../../lambda-extension/_build/extensions/$LAMBDA_ARCHITECTURE/instana-lambda-extension layer/include/$LAMBDA_ARCHITECTURE/instana-lambda-extension
251251
fi
252252

@@ -260,7 +260,7 @@ if [[ $BUILD_LAYER_WITH == local ]]; then
260260
npm --loglevel=warn pack
261261
mv instana-aws-lambda-auto-wrap-*.tgz $LAYER_WORKDIR/instana-aws-lambda-auto-wrap.tgz
262262

263-
popd > /dev/null
263+
popd >/dev/null
264264

265265
# Install locally built packages (basically extracting them into node_modules) to prepare the structure that is
266266
# expected from an AWS Node.js Lambda layer.
@@ -300,7 +300,7 @@ cp ../../../aws-lambda-auto-wrap/src/utils.js nodejs/node_modules/instana-aws-la
300300
echo "step 5/9: creating local zip file with layer contents"
301301
zip -qr $ZIP_PREFIX .
302302
mv $ZIP_NAME ..
303-
popd > /dev/null
303+
popd >/dev/null
304304

305305
export AWS_PAGER=""
306306
export AWS_MAX_ATTEMPTS=$AWS_CLI_RETRY_MAX_ATTEMPTS
@@ -310,7 +310,6 @@ BUILD_SHOULD_FAIL=0
310310
if [[ -z $SKIP_AWS_PUBLISH_LAYER ]]; then
311311
echo "step 6/9: publishing $ZIP_NAME as AWS Lambda layer $LAYER_NAME to specifed regions"
312312

313-
314313
for region in "${REGIONS[@]}"; do
315314
if [[ "$SKIPPED_REGIONS" == *"$region"* ]]; then
316315
echo "Skipping region: $region"
@@ -338,20 +337,20 @@ if [[ -z $SKIP_AWS_PUBLISH_LAYER ]]; then
338337

339338
# See https://docs.aws.amazon.com/cli/latest/reference/lambda/publish-layer-version.html for documentation.
340339
# NOTE: --compatible-architectures $LAMBDA_ARCHITECTURE is not working in all regions.
341-
lambda_layer_version=$( \
340+
lambda_layer_version=$(
342341
aws \
343-
--region $region \
344-
$aws_cli_timeout_options \
345-
lambda \
342+
--region $region \
343+
$aws_cli_timeout_options \
344+
lambda \
346345
publish-layer-version \
347346
--layer-name $LAYER_NAME \
348347
--description "Provides Instana tracing and monitoring for AWS Lambdas (@instana/aws-lambda@$VERSION)" \
349348
--license-info $LICENSE \
350349
--zip-file fileb://$ZIP_NAME \
351350
--output json \
352-
--compatible-runtimes $SUPPORTED_RUNTIMES \
353-
| jq '.Version' \
354-
) || true # NOTE: If the upload fails, the bash script should not fail.
351+
--compatible-runtimes $SUPPORTED_RUNTIMES |
352+
jq '.Version'
353+
) || true # NOTE: If the upload fails, the bash script should not fail.
355354

356355
if [[ -z $lambda_layer_version ]] || [[ ! $lambda_layer_version =~ ^[0-9]+$ ]]; then
357356
echo " + ERROR: Failed to publish layer in region $region, continuing to the next region."
@@ -364,10 +363,10 @@ if [[ -z $SKIP_AWS_PUBLISH_LAYER ]]; then
364363
if [[ $lambda_layer_version =~ ^[0-9]+$ ]]; then
365364
echo " + setting required permission on Lambda layer $LAYER_NAME / version $lambda_layer_version in region $region"
366365
aws \
367-
--region $region \
368-
$aws_cli_timeout_options \
369-
lambda \
370-
add-layer-version-permission \
366+
--region $region \
367+
$aws_cli_timeout_options \
368+
lambda \
369+
add-layer-version-permission \
371370
--layer-name $LAYER_NAME \
372371
--version-number $lambda_layer_version \
373372
--statement-id public-permission-all-accounts \
@@ -377,17 +376,17 @@ if [[ -z $SKIP_AWS_PUBLISH_LAYER ]]; then
377376
else
378377
echo " + WARNING: Lambda layer version $lambda_layer_version does not seem to be numeric, will not set permissions in region $region"
379378
fi
380-
done <<< "$REGIONS"
379+
done <<<"$REGIONS"
381380
else
382381
echo "step 6/9: publishing AWS Lambda layer $LAYER_NAME (skipping)"
383382
fi
384383

385-
# NOTE: We currently build and publish only x86-based images.
386-
# Support for ARM-based images is not yet added.(TODO: INSTA-36216)
384+
# NOTE: We currently build and publish only x86-based images.
385+
# Support for ARM-based images is not yet added.(TODO: INSTA-36216)
387386
if [[ -z $SKIP_DOCKER_IMAGE ]]; then
388387
echo "Step 7/9: Building Docker image for Lambda layer targeting Node.js version $NODEJS_DEV_VERSION"
389388

390-
# Build the Docker image for the specified Node.js version
389+
# Build the Docker image for the specified Node.js version
391390
docker build --build-arg NODEJS_VERSION=$NODEJS_DEV_VERSION . -t "$DOCKER_IMAGE_NAME:$VERSION"
392391

393392
# NOTE: serverless/ci/pipeline.yaml passes PACKAGE_VERSION=1 for 1.x branch
@@ -424,4 +423,4 @@ rm -rf $ZIP_NAME
424423
if [[ $BUILD_SHOULD_FAIL -eq 1 ]]; then
425424
echo "Error: At least one layer upload failed. Exiting with error code 1."
426425
exit 1
427-
fi
426+
fi

0 commit comments

Comments
 (0)