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

feat(cli): support for matching notices with arbitrary module names #19088

Merged
merged 32 commits into from Feb 22, 2022

Conversation

otaviomacedo
Copy link
Contributor

@otaviomacedo otaviomacedo commented Feb 22, 2022

This change allows us to publish notices to match any arbitrary module or
construct. For example, a notice that targets the component

{
    "name": "@aws-cdk/aws-apigatewayv2-alpha",
    "version": ">=2.10.0"
}

will be displayed to the user if they have in their cloud assembly a resource of
type @aws-cdk/aws-apigatewayv2-alpha.HttpStage or
@aws-cdk/aws-apigatewayv2-alpha.HttpApi or any other construct from the
apigatewayv2 module, as long as it was built using some version of the
module above or equal to 2.10.0.

We can also target a specific construct, instead:

{
    "name": "@aws-cdk/aws-apigatewayv2-alpha.HttpStage",
    "version": ">=2.10.0"
}

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

@gitpod-io
Copy link

gitpod-io bot commented Feb 22, 2022

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Feb 22, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 22, 2022
Otavio Macedo added 2 commits February 22, 2022 11:06
Type of main updated;
Refresh doesn't force a cache update
Base automatically changed from otaviom/notices to master February 22, 2022 12:35
# Conflicts:
#	packages/aws-cdk/README.md
#	packages/aws-cdk/lib/notices.ts
#	packages/aws-cdk/test/notices.test.ts
@otaviomacedo otaviomacedo marked this pull request as ready for review February 22, 2022 13:13
@otaviomacedo otaviomacedo requested review from a team, kaizencc, rix0rrr and eladb February 22, 2022 13:13
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Feb 22, 2022
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.

Approved modulo small changes

@@ -206,8 +207,23 @@ export class NoticeFilter {
if (this.acknowledgedIssueNumbers.has(notice.issueNumber)) {
return false;
}

const components = flatMap(notice.components, component => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could do with a comment

* A node in the construct tree.
* @internal
*/
interface Node {
Copy link
Contributor

Choose a reason for hiding this comment

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

Node is very minimal, given that we could have a lot of trees going on. ConstructTreeInfoNode or something?

function match(query: Component[], tree: Node): boolean {
return some(tree, node => {
return query.some(component =>
node.constructInfo?.fqn.startsWith(component.name) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but we should also check that the component.name is followed by either . or the end of the string.

We don't want:

{ name: '@aws-cdk/aws-events' }

To match

@aws-cdk/aws-events-targets

@otaviomacedo otaviomacedo removed the pr/do-not-merge This PR should not be merged at this time. label Feb 22, 2022
@mergify
Copy link
Contributor

mergify bot commented Feb 22, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 6325423
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit a87dee7 into master Feb 22, 2022
@mergify mergify bot deleted the otaviom/arbitrary-components branch February 22, 2022 16:37
@mergify
Copy link
Contributor

mergify bot commented Feb 22, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants