fix(ecr-assets): handle Docker 27.4+ output format in TarballImageAsset#33967
fix(ecr-assets): handle Docker 27.4+ output format in TarballImageAsset#33967mergify[bot] merged 4 commits intoaws:mainfrom
Conversation
…eAsset The TarballImageAsset class was failing to properly extract image IDs from Docker 27.4+ output due to a format change from "Loaded image: <digest>" to "Loaded image ID: <digest>". This change: - Introduces a more flexible regex pattern that handles both output formats - Extracts the pattern to a shared constant for consistency - Adds unit tests to verify compatibility with both formats - Ensures backward compatibility with older Docker versions Fixes aws#33428
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33967 +/- ##
=======================================
Coverage 83.98% 83.98%
=======================================
Files 120 120
Lines 6976 6976
Branches 1178 1178
=======================================
Hits 5859 5859
Misses 1005 1005
Partials 112 112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Exemption Request: The unit test already validate the correct extraction of the image ID. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #33428.
Reason for this change
The TarballImageAsset class was failing to properly extract image IDs from Docker 27.4+ output due to a format change from "Loaded image: " to "Loaded image ID: ". This caused the sed command to fail to properly extract the image ID, resulting in an invalid tag format.
After reviewing Docker CLI issue docker/cli#2212 (open since 2019), I found that Docker has actually had two distinct output formats for the
docker loadcommand for some time:See:
https://github.com/moby/moby/blob/37f866285af6910f838c762912dfd57396783b72/image/tarexport/load.go#L140-L159
While the issue was triggered by Docker 27.4, the underlying problem is that our code was only handling one of these output formats. We need a solution that handles both formats.
Description of changes
s/Loaded image[^:]*: //g) that handles both output formatsDOCKER_LOAD_OUTPUT_REGEXfor consistency and maintainabilitytarball-asset.tsto use the new regex patternThis approach makes our code more robust against variations in Docker's output format.
Describe any new or updated permissions being added
No new or updated IAM permissions are needed for this change.
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license