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

Extend AWS ECR regex for c2s support #20648

Merged
merged 14 commits into from
Aug 8, 2024

Conversation

ethanchowell
Copy link
Contributor

@ethanchowell ethanchowell commented Jun 22, 2024

Thank you for contributing to Harbor!

Comprehensive Summary of your change

This PR extends the ecr regex check for c2s regions that don't follow the amazonaws domain convention.

Issue being fixed

Fixes #(issue)

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@ethanchowell ethanchowell requested a review from a team as a code owner June 22, 2024 02:33
@ethanchowell ethanchowell changed the title Extend regex for c2s support Extend AWS ECR regex for c2s support Jun 22, 2024
@MinerYang
Copy link
Contributor

MinerYang commented Jun 24, 2024

Hi @ethanchowell ,

Thanks for your contributions!
Could you help to provide the related official doc for this regex definition if there's any?

Best,
Miner

@MinerYang MinerYang assigned chlins and unassigned stonezdj and MinerYang Jun 24, 2024
@ethanchowell
Copy link
Contributor Author

ethanchowell commented Jun 24, 2024

I'm not aware of any official docs, but can point to the ecr-credential-helper that implements this pattern successfully. Slightly modified of course to account for existing tests within the project.

@chlins chlins added the release-note/update Update or Fix label Jul 4, 2024
@chlins
Copy link
Member

chlins commented Jul 4, 2024

@ethanchowell Hi, thanks for your contribution, please resolve the DCO failure in CI.

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.23%. Comparing base (c8c11b4) to head (3a26c5d).
Report is 249 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #20648       +/-   ##
===========================================
+ Coverage   45.36%   66.23%   +20.86%     
===========================================
  Files         244     1045      +801     
  Lines       13333   113501   +100168     
  Branches     2719     2845      +126     
===========================================
+ Hits         6049    75174    +69125     
- Misses       6983    34214    +27231     
- Partials      301     4113     +3812     
Flag Coverage Δ
unittests 66.23% <100.00%> (+20.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/pkg/reg/adapter/awsecr/adapter.go 68.62% <100.00%> (ø)

... and 1286 files with indirect coverage changes

Signed-off-by: Ethan Howell <[email protected]>
Signed-off-by: Ethan Howell <[email protected]>
Signed-off-by: Ethan Howell <[email protected]>
Signed-off-by: Ethan Howell <[email protected]>
@@ -67,7 +67,7 @@ func parseAccountRegion(url string) (string, string, error) {
if rs == nil {
return "", "", errors.New("bad aws url")
}
return rs[1], rs[2], nil
return rs[1], rs[3], nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add length check for rs before this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to add it, but shouldn't that always evaluate to true based on the docs for FindStringSubmatch? In the event of no match it would just be nil.

@@ -64,10 +64,10 @@ func newAdapter(registry *model.Registry) (*adapter, error) {

func parseAccountRegion(url string) (string, string, error) {
rs := ecrRegexp.FindStringSubmatch(url)
if rs == nil {
if rs == nil || len(rs) < 3 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the following logic extract the rs[3], so it may be necessary to use < 4 here instead?

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chlins
Copy link
Member

chlins commented Aug 2, 2024

@vincentni Hi, please help to review this PR as well if you have time, thanks.

@chlins chlins enabled auto-merge (squash) August 6, 2024 02:54
@chlins
Copy link
Member

chlins commented Aug 6, 2024

@Vad1mo Please help to review this PR as well, thanks.

Copy link
Contributor

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chlins chlins merged commit ec5dc09 into goharbor:main Aug 8, 2024
10 checks passed
kunal-511 pushed a commit to kunal-511/harbor_local that referenced this pull request Aug 22, 2024
* Extend regex for c2s support

Signed-off-by: Ethan Howell <[email protected]>

* Add more test cases

Signed-off-by: Ethan Howell <[email protected]>

* Update region

Signed-off-by: Ethan Howell <[email protected]>

* Fix region parsing

Signed-off-by: Ethan Howell <[email protected]>

* Add length check

Signed-off-by: Ethan Howell <[email protected]>

* Update check

Signed-off-by: Ethan Howell <[email protected]>

---------

Signed-off-by: Ethan Howell <[email protected]>
Signed-off-by: kunal-511 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/update Update or Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants