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 notices #18936

Merged
merged 26 commits into from Feb 22, 2022
Merged

feat(cli): support for notices #18936

merged 26 commits into from Feb 22, 2022

Conversation

otaviomacedo
Copy link
Contributor

@otaviomacedo otaviomacedo commented Feb 11, 2022

Features

  • notices show up on every cdk command
  • cdk acknowledge will acknowledge an issue by id, scoped to individual cdk apps
  • cdk notices always returns relevant notices
  • context flag 'notices' = false will hide notices always
  • notices are filtered by cli version
  • notices are filtered by v2 framework version
  • notices are filtered by v1 framework version
  • --no-notices option
  • think about versioning for v2 alpha modules -- this will be left for a separate PR
  • --fail-on-notices option -- this will be left for a separate PR

Example:

Screenshot 2022-02-21 at 20 22 24


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 11, 2022

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Feb 11, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 11, 2022
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

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

The PR description right now has a list of features I think I've addressed as well as other considerations I have yet to tackle.

packages/aws-cdk/lib/notices.ts Outdated Show resolved Hide resolved
packages/aws-cdk/bin/cdk.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Show resolved Hide resolved
@kaizencc kaizencc marked this pull request as ready for review February 17, 2022 18:42
@otaviomacedo otaviomacedo requested a review from a team February 19, 2022 14:48
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.

Overall looks good! Some small comments on code organization

packages/aws-cdk/lib/cli.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cli.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/notices.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/notices.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cli.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/notices.ts Outdated Show resolved Hide resolved
}

interface CachedNotices {
expiration: number,
Copy link
Contributor

Choose a reason for hiding this comment

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

I still find this a little weird. Why wouldn't we use the mtime of the cached notices file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're probably right. But I think I've got a bit of a tunnel vision here: the code for retrieving the contents (including some form of timestamp) and the code for comparison/retrieval should be kept separate. So we need some data structure to send data from one to the other, which means this interface would still exist. The only difference is that the expiration time would be a little more hidden.

Now tell me how I am wrong :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, you're not wrong. I guess it doesn't matter. I'm having a hard time thinking up cases in which they produce different results.

packages/aws-cdk/lib/notices.ts Show resolved Hide resolved
packages/aws-cdk/test/notices.test.ts Outdated Show resolved Hide resolved
@eladb
Copy link
Contributor

eladb commented Feb 21, 2022

Can you add a screenshot with an example?

@@ -227,6 +230,8 @@ if (!process.stdout.isTTY) {
}

async function initCommandLine() {
void refreshNotices().then(_ => debug('Notices refreshed'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably also needs a catch.

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 some tiny fixes

}

case 'notices':
// This is a valid command, but we're postponing its execution
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have put the command here, but I guess you're not doing that on purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if we put the command here, it will show the notices again at the end, unless we have some way of signaling that notices were already shown and there is no need to show it again. I don't like either approach, but this one seems a bit cleaner.

}
} finally {
await version.displayVersionMessage();
}

async function main(command: string, args: any): Promise<number | string | {} | void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Signature should be changed to Promise<number | undefined>.

}

export async function refreshNotices() {
const dataSource = dataSourceReference(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this necessarily MUST ignore the cache... just that IF we're going to refresh, we'd better do it early so that we don't add latency later. It's perfectly fine not to refresh here if the data is not stale yet.

}

interface CachedNotices {
expiration: number,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, you're not wrong. I guess it doesn't matter. I'm having a hard time thinking up cases in which they produce different results.

@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Feb 22, 2022
Type of main updated;
Refresh doesn't force a cache update
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@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).

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

6 participants