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

chore(appconfig): fix some awslint errors, explicitly exempt others #28671

Merged
merged 6 commits into from
Jan 18, 2024

Conversation

chenjane-dev
Copy link
Contributor

@chenjane-dev chenjane-dev commented Jan 11, 2024

Auditing awslint errors.

Reasons for keeping current list of exemptions:

  • "no-unused-type:@aws-cdk/aws-appconfig-alpha.PredefinedDeploymentStrategyId" - will be fixed in a separate PR.
  • "props-physical-name:@aws-cdk/aws-appconfig-alpha.ApplicationProps"
    "props-physical-name:@aws-cdk/aws-appconfig-alpha.DeploymentStrategyProps"
    "props-physical-name:@aws-cdk/aws-appconfig-alpha.EnvironmentProps"
    "props-physical-name:@aws-cdk/aws-appconfig-alpha.ExtensionProps" - will be fixed in a separate PR.
  • "events-method-signature" - exempting because appconfig handles their events without cloudwatch events
  • "events-generic" - exempting because appconfig handles their events without cloudwatch events

Closes #27894 alongside #28742 and #28743


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

@aws-cdk-automation aws-cdk-automation requested a review from a team January 11, 2024 20:01
@github-actions github-actions bot added valued-contributor [Pilot] contributed between 6-12 PRs to the CDK p2 bug This issue is a bug. effort/small Small work item – less than a day of effort p1 and removed p2 labels Jan 11, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 11, 2024
@paulhcsun paulhcsun added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jan 16, 2024
"props-physical-name:@aws-cdk/aws-appconfig-alpha.ApplicationProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.DeploymentStrategyProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.EnvironmentProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.ExtensionProps",
"events-in-interface",
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this awslint error fixed in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@chenjane-dev I've done my best to explain the specific linter errors below. There's a few points that require further discussion that I will follow up with later.


"no-unused-type:@aws-cdk/aws-appconfig-alpha.PredefinedDeploymentStrategyId" - This is for customers to use in case they want to import an AppConfig predefined deployment strategy

  • the reason why this linter error flares up in this use case is because we are specifying an enum into a property that allows a string. I'm not sure if this even works for non-TS languages, but either way, this is a CDK anti-pattern. The correct path forward imo is to make a DeploymentStrategyId enum-like class with a public constructor to specify arbitrary strings and the same static methods for the Predefined Ids. And make that the type for deploymentStrategyId, which is a breaking change.

"props-physical-name:@aws-cdk/aws-appconfig-alpha.ApplicationProps"
"props-physical-name:@aws-cdk/aws-appconfig-alpha.DeploymentStrategyProps"
"props-physical-name:@aws-cdk/aws-appconfig-alpha.EnvironmentProps"
"props-physical-name:@aws-cdk/aws-appconfig-alpha.ExtensionProps" - These names are not prefixed by [cfnResource]. This is to help distinguish that these parameters are not set at deployment time.

  • i think you misunderstand this one. The ask here is to standardize the naming of the resources. Instead of name under ApplicationProps, it should be applicationName. This is to standardize with our other resources i.e. lambda function name is functionName. Remediation here is to make breaking changes to all name props with [Resource]Name.

"events-method-signature" - These on methods are not associated with CloudWatch Events

The reason for the linter rule is to reserve onXxx APIs for CloudWatch Events. This provides a CDK pattern where any API that begins with on is an events API. Therefore, your justification does not really move the needle for me. In this case, I see that the phrasing comes from appConfig itself. I will double check internally. If we do accept the exemption, I would still want you to specify each individual linter exemption rather than turning off the rule entirely (I didn't have time to do this when I was turning on awslint). Feel free to add that in to this PR.


"events-generic" - There already is a generic method. This is named on instead of onEvent for clearer naming since the action point will be passed in

The issue is the same as above -- are we ok with onXxx methods not being CW event methods. Is there any part of the original RFC that discusses this? And again, if we go through with the exemptions it will have to be each individual exemption.


  • Finally, though not a blocker to stabilization, all the missing docs present a poor experience for users and should be updated where appropriate.

The first two fixes should come in separate PRs and call out their breaking changes.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 16, 2024
@chenjane-dev
Copy link
Contributor Author

Will follow up with the first two in separate PRs. Added the bottom two individual exceptions. Yes, this was designed and approved through the RFC: https://github.com/aws/aws-cdk-rfcs/blob/main/text/0499-appconfig-constructs.md#example-4

@mergify mergify bot dismissed kaizencc’s stale review January 17, 2024 15:28

Pull request has been modified.

@kaizencc
Copy link
Contributor

Thanks for the quick link @chenjane-dev . I will double check with @otaviomacedo (bar raiser, i believe) and @rix0rrr (linter rule creator) for a final decision

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 17, 2024
"events-method-signature",
"events-generic"
"events-method-signature:@aws-cdk/aws-appconfig-alpha.Application.on",
"events-method-signature:@aws-cdk/aws-appconfig-alpha.Application.onDeploymentBaking",
Copy link
Contributor

Choose a reason for hiding this comment

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

@chenjane-dev nit: i know i told you to add each individual linter exemption, because if not, and we stabilized, then we would be exempting events-method-signature everywhere. However, I don't think we need the individual params[0] and params[1] either. Having the onDeploymentBaking linter error is enough uniqueness i think

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 didn't include them at first but then was getting the errors on the params[0] and params[1]

Copy link
Contributor

Choose a reason for hiding this comment

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

ok i'll check this out for you. seems weird if true but i believe you :)

Copy link
Contributor

Choose a reason for hiding this comment

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

used * to get it to work

@kaizencc kaizencc changed the title chore(appconfig): audit awslint errors chore(appconfig): fix some awslint errors, explicitly exempt others Jan 17, 2024
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.

Sweet!

mergify bot pushed a commit that referenced this pull request Jan 17, 2024
Linter rules caught that CDK standardizes resource name prop as `[resource]Name`. Previously this module only used `name` for the prop.

Follow up from #28671.

BREAKING CHANGE: `ApplicationProps.name` renamed to `ApplicationProps.applicationName`
  - **appconfig**: `EnvironmentProps.name` renamed to `EnvironmentProps.environmentName`
  - **appconfig**: `DeploymentStrategyProps.name` renamed to `DeploymentStrategyProps.deploymentStrategyName`
  - **appconfig**: `ExtensionProps.name` renamed to `ExtensionProps.extensionName`

----

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

mergify bot commented Jan 17, 2024

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

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 17, 2024
Copy link
Contributor

mergify bot commented Jan 17, 2024

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

mergify bot pushed a commit that referenced this pull request Jan 17, 2024
…her than a string (#28743)

Previously, we were typing this as a `string` and providing an enum for `PredefinedDeploymentStrategyId`s. This is a CDK anti-pattern because this makes the enum undiscoverable, since users see that it is typed only as a `string`. It also may not work in non-TS languages. Instead, we are moving the type to explicitly be an enum-like class.

Follow up from #28671.

BREAKING CHANGE: `deploymentStrategyId` prop in `fromDeploymentStrategyId` now takes a `DeploymentStrategyId` rather than a `string`. To import a predefined deployment strategy id, use `DeploymentStrategyId.CANARY_10_PERCENT_20_MINUTES`. Otherwise, use `DeploymentStrategyId.fromString('abc123')`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Jan 18, 2024

Thank you for contributing! Your pull request will be updated from main 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
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(appconfig): Linter errors must be audited
4 participants