Skip to content

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

Merged
mergify[bot] merged 32 commits intomasterfrom
otaviom/arbitrary-components
Feb 22, 2022
Merged

feat(cli): support for matching notices with arbitrary module names#19088
mergify[bot] merged 32 commits intomasterfrom
otaviom/arbitrary-components

Conversation

@otaviomacedo
Copy link
Copy Markdown
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
Copy Markdown

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, eladb, kaizencc and rix0rrr 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
Copy Markdown
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

return false;
}

const components = flatMap(notice.components, component => {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants