Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly parse ECR URIs and tags to OSMLContainer #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drduhe
Copy link
Collaborator

@drduhe drduhe commented Jan 31, 2025

Issue #, if available: n/a

Notes

Fix: Correctly Support ECR Repository ARN and CONTAINER_URI tags as OSMLContainer configuration options.

This PR enhances the buildFromRepository() method by adding support for importing ECR repositories via ARN (REPOSITORY_ARN) and improving the extraction and handling of container image URIs. Previously, the code:

  • Did not support repository ARNs, requiring only CONTAINER_URI.
  • Incorrectly checked for an ECR ARN instead of an ECR URI.
  • Defaulted to "latest" even when a tag was present in the CONTAINER_URI.

Changes

  • Adds support for REPOSITORY_ARN, allowing users to provide an ECR repository ARN instead of a full image URI.
  • Ensures only one of CONTAINER_URI or REPOSITORY_ARN is provided, preventing misconfigurations.
  • Extracts and respects image tags from CONTAINER_URI (e.g., repo-name:tag).
  • Fixes ECR repository detection by properly recognizing ECR URIs and ARNs.
  • Ensures compatibility with both ECR repositories and external registries (Docker Hub, private registries, etc.).
  • Refactors buildFromRepository() into multiple helper methods for better readability and maintainability.
  • Improved Testing added for entire OSMLContainer construct including new options.
  • Depreciated Inputs have been updated in a few places to remove warnings from builds.

Example Fixes

Before (Bugged) After (Fixed)
No support for ECR repository ARNs (REPOSITORY_ARN was not accepted) Supports importing a full ECR repository via REPOSITORY_ARN
123456789012.dkr.ecr.us-east-1.amazonaws.com/my-repo:1.2.3 was incorrectly assumed to be Docker Hub (docker.io/library/...) Correctly recognized as an ECR image, using the "1.2.3" tag
If a tag was provided in CONTAINER_URI, it was ignored and "latest" was always used The provided tag is now respected
An ECR ARN was required instead of a URI, causing failures Now properly supports ECR repository ARNs and URIs

Impact

  • Supports importing full ECR repositories using REPOSITORY_ARN.
  • Fixes CannotPullContainerError for ECS tasks pulling images from ECR.
  • Prevents accidental usage of :latest when an explicit tag is provided.
  • Improves compatibility with AWS best practices for ECR repositories.
  • Enhances maintainability with a modularized implementation.

This update ensures that users can seamlessly use either an ECR repository ARN or a container image URI, improving flexibility and correctness. 🚀

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

github-actions bot commented Jan 31, 2025

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
91.42% (+0.73% 🔼)
639/699
🟡 Branches
61.58% (+4.44% 🔼)
117/190
🟢 Functions
95.08% (-1.21% 🔻)
58/61
🟢 Lines
91.42% (+0.73% 🔼)
639/699
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / mr_dataplane.ts
91.18%
73.33% (-1.67% 🔻)
100% 91.18%
🟢
... / me_http_endpoint.ts
100%
60% (-6.67% 🔻)
100% 100%
🟢
... / ts_dataplane.ts
86.25% (-0.34% 🔻)
52% 100%
86.25% (-0.34% 🔻)

Test suite run success

42 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from 8bff05b

@drduhe drduhe force-pushed the fix/fix-osml-container-uri branch 11 times, most recently from 2927265 to a23d9d8 Compare February 4, 2025 18:18
@drduhe drduhe force-pushed the fix/fix-osml-container-uri branch 2 times, most recently from bb0cff7 to d55a268 Compare February 10, 2025 17:14
@drduhe drduhe force-pushed the fix/fix-osml-container-uri branch from d55a268 to 8bff05b Compare February 10, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants