Skip to content

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Apr 3, 2025

Issue # (if applicable)

Closes #34031

Reason for this change

The fromLookup method causes an error if the target repository was not found. However it would be also good not to cause an error and to return dummy value in that case.

Now, with the PR merged in aws-cdk-cli ([email protected]), we can ignore errors and return dummy value with mustExist option in CC API Provider.

Description of changes

  • Added the mustExist option in RepositoryLookupOptions.
    • Pass it to mustExist for ContextProvider.getValue
  • Added the static isLookupDummy method to check whether the repository is dummy.

ref PR:

Describe any new or updated permissions being added

Description of how you validated changes

Both unit and integ tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Apr 3, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 3, 2025 08:47
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Apr 3, 2025
@github-actions github-actions bot added the feature-request A feature should be added or improved. label Apr 3, 2025
Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (0923b5e) to head (74d3939).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #34030   +/-   ##
=======================================
  Coverage   83.98%   83.98%           
=======================================
  Files         120      120           
  Lines        6976     6976           
  Branches     1178     1178           
=======================================
  Hits         5859     5859           
  Misses       1005     1005           
  Partials      112      112           
Flag Coverage Δ
suite.unit 83.98% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 83.98% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 74d3939
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 3, 2025
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

(my concerns are summarized below)

mustExist: false,
});

if (ecr.Repository.isLookupDummy(dummy)) {
Copy link
Contributor

@rix0rrr rix0rrr Apr 3, 2025

Choose a reason for hiding this comment

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

I think I'd rather have a new lookup function that returns IRepository | undefined.


That new lookup function would also be a perfect place to attach disclaimers that I'm 99% sure most users will not expect, such as:

  • The result of this lookup is cached in context at the time of synth. Therefore:
    • You must have access to all environments you want to deploy this to at synth time
    • The lookup does not run at deploy time, so if the repository gets created/deleted between synth time and deploy time, the behavior will be not what you expect.
    • After one successful synth, if a user regrets the decision and want to change it (i.e., externally delete/create the resource), the user has clear the context entry before trying again.

I'm sure there's more that I can't think of right now.

Are we 100% confident offering this feature will lead to a good user experience? Because I'm concerned it will end up being a footgun.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm... You have a point, maybe we can't be 100% sure...
I'll drop this PR for now. If I get another good idea I might reopen it.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 3, 2025
@go-to-k go-to-k closed this Apr 4, 2025
@go-to-k go-to-k deleted the ecr-dummy branch April 4, 2025 06:09
Copy link
Contributor

github-actions bot commented Apr 4, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ecr: allow fromLookup method to return dummy repository without error if target repository was not found
3 participants