Skip to content

Commit 5407bb2

Browse files
authored
refactor!: rename registry_id and change type (#295)
* refactor: change name and type of account parameter * fix: run env subst on ORB_STR_ACCOUNT_ID * doc: update usage example * chore: update descriptions and messages
1 parent 699f3da commit 5407bb2

File tree

9 files changed

+38
-35
lines changed

9 files changed

+38
-35
lines changed

src/commands/build_and_push_image.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ description: >
33
Log into Amazon ECR, build and push a Docker image to the specified repository.
44
NOTE: Some commands may not work with AWS CLI Version 1.
55
parameters:
6-
registry_id:
7-
type: env_var_name
8-
default: AWS_ACCOUNT_ID
6+
account_id:
7+
type: string
8+
default: ${AWS_ACCOUNT_ID}
99
description: >
1010
The 12 digit AWS id associated with the ECR account.
1111
This field is required
@@ -228,7 +228,7 @@ steps:
228228
- ecr_login:
229229
profile_name: <<parameters.profile_name>>
230230
region: <<parameters.region>>
231-
registry_id: <<parameters.registry_id>>
231+
account_id: <<parameters.account_id>>
232232
public_registry: <<parameters.public_registry>>
233233
- when:
234234
condition: <<parameters.create_repo>>
@@ -255,7 +255,7 @@ steps:
255255
steps: <<parameters.registry_login>>
256256

257257
- build_image:
258-
registry_id: <<parameters.registry_id>>
258+
account_id: <<parameters.account_id>>
259259
repo: <<parameters.repo>>
260260
tag: <<parameters.tag>>
261261
dockerfile: <<parameters.dockerfile>>

src/commands/build_image.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ description: >
33
NOTE: Some commands may not work with AWS CLI Version 1.
44
55
parameters:
6-
registry_id:
7-
type: env_var_name
8-
default: AWS_ACCOUNT_ID
6+
account_id:
7+
type: string
8+
default: ${AWS_ACCOUNT_ID}
99
description: >
10-
The 12 digit AWS Registry ID associated with the ECR account.
10+
The 12 digit AWS Account ID associated with the ECR account.
1111
This field is required
1212
1313
repo:
@@ -116,7 +116,7 @@ steps:
116116
ORB_EVAL_PATH: <<parameters.path>>
117117
ORB_STR_DOCKERFILE: <<parameters.dockerfile>>
118118
ORB_STR_PROFILE_NAME: <<parameters.profile_name>>
119-
ORB_ENV_REGISTRY_ID: <<parameters.registry_id>>
119+
ORB_STR_ACCOUNT_ID: <<parameters.account_id>>
120120
ORB_STR_REGION: <<parameters.region>>
121121
ORB_STR_PLATFORM: <<parameters.platform>>
122122
ORB_BOOL_PUBLIC_REGISTRY: <<parameters.public_registry>>

src/commands/ecr_login.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ description: >
33
NOTE: Some commands may not work with AWS CLI Version 1.
44
55
parameters:
6-
registry_id:
7-
type: env_var_name
8-
default: AWS_ACCOUNT_ID
6+
account_id:
7+
type: string
8+
default: ${AWS_ACCOUNT_ID}
99
description: >
1010
The 12 digit AWS id associated with the ECR account.
1111
This field is required
@@ -38,7 +38,7 @@ steps:
3838
name: Log into Amazon ECR with profile <<parameters.profile_name>>
3939
environment:
4040
ORB_STR_PROFILE_NAME: <<parameters.profile_name>>
41-
ORB_ENV_REGISTRY_ID: <<parameters.registry_id>>
41+
ORB_STR_ACCOUNT_ID: <<parameters.account_id>>
4242
ORB_STR_REGION: <<parameters.region>>
4343
ORB_BOOL_PUBLIC_REGISTRY: <<parameters.public_registry>>
4444
ORB_STR_AWS_DOMAIN: <<parameters.aws_domain>>

src/commands/push_image.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ description: >
22
Install AWS CLI Version 2 and configure credentials if needed to push a container image to the Amazon ECR registry
33
NOTE: Some commands may not work with AWS CLI Version 1.
44
parameters:
5-
registry_id:
6-
type: env_var_name
7-
default: AWS_ACCOUNT_ID
5+
account_id:
6+
type: string
7+
default: ${AWS_ACCOUNT_ID}
88
description: >
9-
The 12 digit AWS Registry ID associated with the ECR account.
9+
The 12 digit AWS Account ID associated with the ECR account.
1010
This field is required
1111
region:
1212
type: string
@@ -44,6 +44,6 @@ steps:
4444
ORB_STR_TAG: << parameters.tag >>
4545
ORB_BOOL_PUBLIC_REGISTRY: <<parameters.public_registry>>
4646
ORB_STR_PUBLIC_REGISTRY_ALIAS: <<parameters.public_registry_alias>>
47-
ORB_ENV_REGISTRY_ID: << parameters.registry_id >>
47+
ORB_STR_ACCOUNT_ID: << parameters.account_id >>
4848
ORB_STR_AWS_DOMAIN: <<parameters.aws_domain>>
4949
command: << include(scripts/push_image.sh) >>

src/examples/simple_build_and_push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ usage:
4444
#Your AWS region
4545
region: ${AWS_DEFAULT_REGION}
4646

47-
# name of env var storing your ECR Registry ID
48-
registry_id: AWS_ACCOUNT_ID
47+
# Your AWS account ID. use ${variable_name} if stored as an environment variable \
48+
account_id: ${AWS_ACCOUNT_ID}
4949

5050
# ECR image tags (comma separated string), defaults to "latest"
5151
tag: latest,myECRRepoTag

src/jobs/build_and_push_image.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ parameters:
1212
type: executor
1313
default: default
1414

15-
registry_id:
16-
type: env_var_name
17-
default: AWS_ACCOUNT_ID
15+
account_id:
16+
type: string
17+
default: ${AWS_ACCOUNT_ID}
1818
description: >
1919
The 12 digit AWS id associated with the ECR account.
2020
This field is required
@@ -208,7 +208,7 @@ parameters:
208208
209209
steps:
210210
- build_and_push_image:
211-
registry_id: <<parameters.registry_id>>
211+
account_id: <<parameters.account_id>>
212212
repo: <<parameters.repo>>
213213
tag: <<parameters.tag>>
214214
dockerfile: <<parameters.dockerfile>>

src/scripts/docker_buildx.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ ORB_STR_REPO="$(circleci env subst "${ORB_STR_REPO}")"
44
ORB_STR_TAG="$(circleci env subst "${ORB_STR_TAG}")"
55
ORB_EVAL_PATH="$(eval echo "${ORB_EVAL_PATH}")"
66
ORB_STR_AWS_DOMAIN="$(echo "${ORB_STR_AWS_DOMAIN}" | circleci env subst)"
7-
ORB_VAL_ACCOUNT_URL="${!ORB_ENV_REGISTRY_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
7+
ORB_STR_ACCOUNT_ID="$(circleci env subst "${ORB_STR_ACCOUNT_ID}")"
8+
ORB_VAL_ACCOUNT_URL="${ORB_STR_ACCOUNT_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
89
ORB_STR_PUBLIC_REGISTRY_ALIAS="$(circleci env subst "${ORB_STR_PUBLIC_REGISTRY_ALIAS}")"
910
ORB_STR_EXTRA_BUILD_ARGS="$(echo "${ORB_STR_EXTRA_BUILD_ARGS}" | circleci env subst)"
1011
ORB_EVAL_BUILD_PATH="$(eval echo "${ORB_EVAL_BUILD_PATH}")"
@@ -19,8 +20,8 @@ number_of_tags_in_ecr=0
1920
IFS=', ' read -ra platform <<<"${ORB_STR_PLATFORM}"
2021
number_of_platforms="${#platform[@]}"
2122

22-
if [ -z "${!ORB_ENV_REGISTRY_ID}" ]; then
23-
echo "The registry ID is not found. Please add the registry ID as an environment variable in CicleCI before continuing."
23+
if [ -z "${ORB_STR_ACCOUNT_ID}" ]; then
24+
echo "The account ID is not found. Please add the account ID before continuing."
2425
exit 1
2526
fi
2627

@@ -32,7 +33,7 @@ fi
3233
IFS="," read -ra DOCKER_TAGS <<<"${ORB_STR_TAG}"
3334
for tag in "${DOCKER_TAGS[@]}"; do
3435
if [ "${ORB_BOOL_SKIP_WHEN_TAGS_EXIST}" -eq "1" ] || [ "${ORB_BOOL_SKIP_WHEN_TAGS_EXIST}" = "true" ]; then
35-
docker_tag_exists_in_ecr=$(aws "${ECR_COMMAND}" describe-images --profile "${ORB_STR_PROFILE_NAME}" --registry-id "${!ORB_ENV_REGISTRY_ID}" --region "${ORB_STR_REGION}" --repository-name "${ORB_STR_REPO}" --query "contains(imageDetails[].imageTags[], '${tag}')")
36+
docker_tag_exists_in_ecr=$(aws "${ECR_COMMAND}" describe-images --profile "${ORB_STR_PROFILE_NAME}" --registry-id "${ORB_STR_ACCOUNT_ID}" --region "${ORB_STR_REGION}" --repository-name "${ORB_STR_REPO}" --query "contains(imageDetails[].imageTags[], '${tag}')")
3637
if [ "${docker_tag_exists_in_ecr}" = "true" ]; then
3738
docker pull "${ORB_VAL_ACCOUNT_URL}/${ORB_STR_REPO}:${tag}"
3839
number_of_tags_in_ecr=$((number_of_tags_in_ecr += 1))

src/scripts/ecr_login.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/bash
22
ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")"
33
ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")"
4-
ORB_VAL_ACCOUNT_URL="${!ORB_ENV_REGISTRY_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
4+
ORB_STR_ACCOUNT_ID="$(circleci env subst "${ORB_STR_ACCOUNT_ID}")"
5+
ORB_VAL_ACCOUNT_URL="${ORB_STR_ACCOUNT_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
56
ECR_COMMAND="ecr"
67

7-
if [ -z "${!ORB_ENV_REGISTRY_ID}" ]; then
8-
echo "The registry ID is not found. Please add the registry ID as an environment variable in CicleCI before continuing."
8+
if [ -z "${ORB_STR_ACCOUNT_ID}" ]; then
9+
echo "The account ID is not found. Please add the account ID before continuing."
910
exit 1
1011
fi
1112

src/scripts/push_image.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
ORB_STR_REPO="$(circleci env subst "${ORB_STR_REPO}")"
33
ORB_STR_TAG="$(circleci env subst "${ORB_STR_TAG}")"
44
ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")"
5-
ORB_VAL_ACCOUNT_URL="${!ORB_ENV_REGISTRY_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
5+
ORB_STR_ACCOUNT_ID="$(circleci env subst "${ORB_STR_ACCOUNT_ID}")"
6+
ORB_VAL_ACCOUNT_URL="${ORB_STR_ACCOUNT_ID}.dkr.ecr.${ORB_STR_REGION}.${ORB_STR_AWS_DOMAIN}"
67
ORB_STR_PUBLIC_REGISTRY_ALIAS="$(circleci env subst "${ORB_STR_PUBLIC_REGISTRY_ALIAS}")"
78

8-
if [ -z "${!ORB_ENV_REGISTRY_ID}" ]; then
9-
echo "The registry ID is not found. Please add the registry ID as an environment variable in CicleCI before continuing."
9+
if [ -z "${ORB_STR_ACCOUNT_ID}" ]; then
10+
echo "The account ID is not found. Please add the account ID before continuing."
1011
exit 1
1112
fi
1213

0 commit comments

Comments
 (0)