Skip to content

Commit 1b5c555

Browse files
authored
feat: image tag mutability is configurable (#375)
* feat: image tag mutability is configurable Signed-off-by: Carlos Juan Gómez Peñalver <[email protected]> * feat: add config to job Signed-off-by: Carlos Juan Gómez Peñalver <[email protected]> * feat: add config to job Signed-off-by: Carlos Juan Gómez Peñalver <[email protected]> --------- Signed-off-by: Carlos Juan Gómez Peñalver <[email protected]>
1 parent ec740b0 commit 1b5c555

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/commands/build_and_push_image.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ parameters:
201201
The alias, key ID, or full ARN of the KMS key can be specified.
202202
default: ""
203203

204+
repo_image_tag_mutability:
205+
type: enum
206+
enum: ["MUTABLE", "IMMUTABLE"]
207+
description: >
208+
The tag mutability setting for the repository. If this parameter is omitted,
209+
the default setting of MUTABLE will be used which will allow image tags to be
210+
overwritten. If IMMUTABLE is specified, all image tags within the repository will
211+
be immutable which will prevent them from being overwritten.
212+
default: "MUTABLE"
213+
204214
use_credentials_helper:
205215
type: boolean
206216
default: true
@@ -248,6 +258,7 @@ steps:
248258
public_registry: <<parameters.public_registry>>
249259
repo_encryption_type: <<parameters.repo_encryption_type>>
250260
encryption_kms_key: <<parameters.repo_encryption_kms_key>>
261+
image_tag_mutability: <<parameters.repo_image_tag_mutability>>
251262
- when:
252263
condition: <<parameters.set_repo_policy>>
253264
steps:

src/commands/create_repo.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ parameters:
4141
The alias, key ID, or full ARN of the KMS key can be specified.
4242
default: ""
4343

44+
image_tag_mutability:
45+
type: enum
46+
enum: ["MUTABLE", "IMMUTABLE"]
47+
description: >
48+
The tag mutability setting for the repository. If this parameter is omitted,
49+
the default setting of MUTABLE will be used which will allow image tags to be
50+
overwritten. If IMMUTABLE is specified, all image tags within the repository will
51+
be immutable which will prevent them from being overwritten.
52+
default: "MUTABLE"
53+
4454
steps:
4555
- run:
4656
name: Create Repository
@@ -52,4 +62,5 @@ steps:
5262
AWS_ECR_BOOL_PUBLIC_REGISTRY: <<parameters.public_registry>>
5363
AWS_ECR_ENUM_ENCRYPTION_TYPE: <<parameters.repo_encryption_type>>
5464
AWS_ECR_STR_ENCRYPTION_KMS_KEY: <<parameters.encryption_kms_key>>
65+
AWS_ECR_STR_IMAGE_TAG_MUTABILITY: <<parameters.image_tag_mutability>>
5566
command: <<include(scripts/create_repo.sh)>>

src/jobs/build_and_push_image.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ parameters:
199199
The alias, key ID, or full ARN of the KMS key can be specified.
200200
default: ""
201201

202+
repo_image_tag_mutability:
203+
type: enum
204+
enum: ["MUTABLE", "IMMUTABLE"]
205+
description: >
206+
The tag mutability setting for the repository. If this parameter is omitted,
207+
the default setting of MUTABLE will be used which will allow image tags to be
208+
overwritten. If IMMUTABLE is specified, all image tags within the repository will
209+
be immutable which will prevent them from being overwritten.
210+
default: "MUTABLE"
211+
202212
aws_domain:
203213
type: string
204214
default: "amazonaws.com"
@@ -246,5 +256,6 @@ steps:
246256
auth: <<parameters.auth>>
247257
repo_encryption_type: <<parameters.repo_encryption_type>>
248258
repo_encryption_kms_key: <<parameters.repo_encryption_kms_key>>
259+
repo_image_tag_mutability: <<parameters.repo_image_tag_mutability>>
249260
use_credentials_helper: <<parameters.use_credentials_helper>>
250261
aws_domain: <<parameters.aws_domain>>

src/scripts/create_repo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ AWS_ECR_EVAL_REGION="$(eval echo "${AWS_ECR_STR_REGION}")"
33
AWS_ECR_EVAL_REPO="$(eval echo "${AWS_ECR_STR_REPO}")"
44
AWS_ECR_EVAL_PROFILE_NAME="$(eval echo "${AWS_ECR_STR_PROFILE_NAME}")"
55
AWS_ECR_EVAL_ENCRYPTION_KMS_KEY="$(eval echo "${AWS_ECR_STR_ENCRYPTION_KMS_KEY}")"
6+
AWS_ECR_EVAL_IMAGE_TAG_MUTABILITY="$(eval echo "${AWS_ECR_STR_IMAGE_TAG_MUTABILITY}")"
67

78
if [ "$AWS_ECR_BOOL_PUBLIC_REGISTRY" == "1" ]; then
89
aws ecr-public describe-repositories --profile "${AWS_ECR_EVAL_PROFILE_NAME}" --region us-east-1 --repository-names "${AWS_ECR_EVAL_REPO}" >/dev/null 2>&1 ||
@@ -27,6 +28,7 @@ else
2728
--profile "${AWS_ECR_EVAL_PROFILE_NAME}" \
2829
--region "${AWS_ECR_EVAL_REGION}" \
2930
--repository-name "${AWS_ECR_EVAL_REPO}" \
31+
--image-tag-mutability "${AWS_ECR_EVAL_IMAGE_TAG_MUTABILITY}" \
3032
--image-scanning-configuration "${IMAGE_SCANNING_CONFIGURATION}" \
3133
--encryption-configuration "${ENCRYPTION_CONFIGURATION}"
3234
fi

0 commit comments

Comments
 (0)