Skip to content

Commit 0438894

Browse files
authored
Feature/extra args (#394)
* Add media type parameter * Fix parameter * Add a default for testing * Change var definition * Add equal sign * Allow any arg as extra arg * Fix shellcheck
1 parent 8a2aa71 commit 0438894

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/commands/tag_image.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ parameters:
2626
description: AWS profile to use
2727
type: string
2828

29+
extra_args:
30+
type: string
31+
default: ""
32+
description: >
33+
Extra flags to pass to AWS CLI.
34+
Pass the desired args using an equal sign (=) instead of an space.
35+
For example, --arg=ARG1, instead of --arg ARG1.
2936
steps:
3037
- run:
3138
name: <<parameters.target_tag>> tag to <<parameters.repo>>:<<parameters.source_tag>>
@@ -35,4 +42,5 @@ steps:
3542
AWS_ECR_STR_TARGET_TAG: <<parameters.target_tag>>
3643
AWS_ECR_BOOL_SKIP_WHEN_TAGS_EXIST: <<parameters.skip_when_tags_exist>>
3744
AWS_ECR_STR_AWS_PROFILE: <<parameters.profile_name>>
45+
AWS_ECR_STR_EXTRA_ARGS: <<parameters.extra_args>>
3846
command: <<include(scripts/tag_image.sh)>>

src/scripts/tag_image.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ if [ "${AWS_ECR_BOOL_SKIP_WHEN_TAGS_EXIST}" -eq 1 ]; then
1313
fi
1414
IFS="," read -ra ECR_TAGS <<<"${AWS_ECR_EVAL_TARGET_TAG}"
1515

16+
extra_args=()
17+
if [ -n "$AWS_ECR_STR_EXTRA_ARGS" ]; then
18+
# shellcheck disable=SC2086
19+
eval 'for p in '$AWS_ECR_STR_EXTRA_ARGS'; do extra_args+=("$p"); done'
20+
fi
21+
1622
for tag in "${ECR_TAGS[@]}"; do
1723
# if skip_when_tags_exist is true
1824
if [ "${AWS_ECR_BOOL_SKIP_WHEN_TAGS_EXIST}" -eq 1 ]; then
1925
# tag image if tag does not exist
2026
if ! echo "${EXISTING_TAGS}" | grep "${tag}"; then
21-
aws ecr put-image --repository-name "${AWS_ECR_EVAL_REPO}" --image-tag "${tag}" --image-manifest "${MANIFEST}" --profile "${AWS_ECR_EVAL_AWS_PROFILE}"
27+
aws ecr put-image --repository-name "${AWS_ECR_EVAL_REPO}" --image-tag "${tag}" --image-manifest "${MANIFEST}" "${extra_args[@]}" --profile "${AWS_ECR_EVAL_AWS_PROFILE}"
2228
else
2329
echo "Tag \"${tag}\" already exists and will be skipped."
2430
fi
2531
# tag image when skip_when_tags_exist is false
2632
else
27-
aws ecr put-image --repository-name "${AWS_ECR_EVAL_REPO}" --image-tag "${tag}" --image-manifest "${MANIFEST}" --profile "${AWS_ECR_EVAL_AWS_PROFILE}"
33+
aws ecr put-image --repository-name "${AWS_ECR_EVAL_REPO}" --image-tag "${tag}" --image-manifest "${MANIFEST}" "${extra_args[@]}" --profile "${AWS_ECR_EVAL_AWS_PROFILE}"
2834
fi
2935
done
3036
set +x

0 commit comments

Comments
 (0)