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(core): Introduced Duration class #2857

Merged
merged 8 commits into from
Jun 20, 2019
Merged

feat(core): Introduced Duration class #2857

merged 8 commits into from
Jun 20, 2019

Conversation

RomainMuller
Copy link
Contributor

This can be used to model durations in a user-friendly way, while
allowing coercion into the desired/required time unit at the usage site.

There is now a default requirement that properties exposed by the APIs
and that have a duration-like name (ending in duration, period,
timeout or ttl) have a type of @aws-cdk/cdk.Duration and do not
contain a unit suffix (Days, Millis, Seconds, Sec, ...).

BREAKING CHANGE: Properties throughout the AWS Construct Libraries that
represent lengths of time have been re-typed to be
@aws-cdk/cdk.Duration instead of number, and were
renamed to exclude any unit indication.


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

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

This can be used to model durations in a user-friendly way, while
allowing coercion into the desired/required time unit at the usage site.

There is now a default requirement that properties exposed by the APIs
and that have a duration-like name (ending in `duration`, `period`,
`timeout` or `ttl`) have a type of `@aws-cdk/cdk.Duration` and do not
contain a unit suffix (`Days`, `Millis`, `Seconds`, `Sec`, ...).

BREAKING CHANGE: Properties throughout the AWS Construct Libraries that
                 represent lengths of time have been re-typed to be
                 `@aws-cdk/cdk.Duration` instead of `number`, and were
                 renamed to exclude any unit indication.
@RomainMuller RomainMuller requested review from skinny85, SoManyHs and a team as code owners June 13, 2019 11:55
packages/@aws-cdk/cdk/lib/duration.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/duration.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

just realized I had some comments pending

1. Dropped the free-floating toSeconds function
2. Added test for unresolved tokens in constructor
3. Made .toString() return a breaking token.
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Looks super slick... See my comment about tokens. I am okay if we want to introduce it at a subsequent PR, but make sure to open an issue.

@@ -88,8 +88,14 @@
"@aws-cdk/aws-s3": "^0.35.0",
"@aws-cdk/cdk": "^0.35.0"
},
"awslint": {
"exclude": [
"duration-prop-type:@aws-cdk/aws-cloudtrail.TrailProps.cloudWatchLogsRetentionTimeDays",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just call this cloudWatchLogsRetention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reckon we should!

packages/@aws-cdk/cdk/test/test.duration.ts Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/resource-policy.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/duration.ts Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/duration.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/duration.ts Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/duration.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/cdk/lib/cfn-resource.ts Show resolved Hide resolved
mergify bot pushed a commit that referenced this pull request Dec 16, 2019
* docs(ecr): fix deprecated requirement maxImageAgeDays

- on [Automatically clean up repositories](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ecr-readme.html\#automatically-clean-up-repositories) of Amazon ECR docs, there is deprecated property using on addLifecycleRule example
- due to introduce of Duration Class(#2857), it should be maxImageAge rather than maxImageAgeDays

* chore(ecr): fix deprecated requirement maxImageAgeDays

- maxImageAgeDays were deprecated since #2857, but still used on comments.
- should be chaged to maxImageAge
- fixes #3273
ed-at-work pushed a commit to ed-at-work/aws-cdk that referenced this pull request Dec 17, 2019
* docs(ecr): fix deprecated requirement maxImageAgeDays

- on [Automatically clean up repositories](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ecr-readme.html\#automatically-clean-up-repositories) of Amazon ECR docs, there is deprecated property using on addLifecycleRule example
- due to introduce of Duration Class(aws#2857), it should be maxImageAge rather than maxImageAgeDays

* chore(ecr): fix deprecated requirement maxImageAgeDays

- maxImageAgeDays were deprecated since aws#2857, but still used on comments.
- should be chaged to maxImageAge
- fixes aws#3273
richardhboyd added a commit to richardhboyd/aws-cdk that referenced this pull request Mar 24, 2020
Fixed example to align with changes from [this commit](aws#2857)
mergify bot pushed a commit that referenced this pull request Mar 25, 2020
Fixed example to align with changes from [this commit](#2857)
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants