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

Fix Quotas service_code/quota_code validation #17992

Merged
merged 2 commits into from
Apr 16, 2021

Conversation

Stretch96
Copy link
Contributor

@Stretch96 Stretch96 commented Mar 9, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Fix Quotas service_code/quota_code validation

Closes #17970

@Stretch96 Stretch96 requested a review from a team as a code owner March 9, 2021 03:52
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/servicequotas Issues and PRs that pertain to the servicequotas service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Mar 9, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 9, 2021
@Stretch96 Stretch96 force-pushed the fix-quotas-code-validation branch 3 times, most recently from fe3275c to 985c8a4 Compare March 9, 2021 04:24
@anGie44 anGie44 self-assigned this Mar 30, 2021
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

Hi @Stretch96 , thank you for this PR! While the custom validation funcs look great and tests are fantastic, the current convention is to use the Terraform Plugin SDK's validation package's helper methods e.g. validation.StringLenBetween(). Apologies for not providing guidance beforehand!

So with that said, refactoring the 2 validationFuncs would be the best next step. To encompass the validation requirements we can use something like:

ValidateFunc: validation.All(
    validation.StringLenBetween(1, 128),
    validation.StringMatch(regexp.MustCompile(`^[A-Za-z][A-Za-z0-9-]*$`), "must begin with a letter and contain only alphanumeric or hyphen characters"),
),
ValidateFunc: validation.All(
    validation.StringLenBetween(1, 63),
    validation.StringMatch(regexp.MustCompile(`^[A-Za-z][A-Za-z0-9-]*$`), "must begin with a letter and contain only alphanumeric or hyphen characters"),
),

With this refactoring, the tests will no longer be needed as the validation package is unit testing in the SDK.

Reach out if you have questions :)

@anGie44 anGie44 added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 1, 2021
@Stretch96
Copy link
Contributor Author

Cool cool, I'll refactor using those 👍

I just copied from the (I think) security group validations and tests

Maybe that'll be my next PR if they need refactoring too Lol

@ghost ghost removed waiting-response Maintainers are waiting on response from community or contributor. labels Apr 1, 2021
@anGie44 anGie44 added the waiting-response Maintainers are waiting on response from community or contributor. label Apr 2, 2021
@anGie44
Copy link
Contributor

anGie44 commented Apr 16, 2021

Hi @Stretch96 👋 , circling back here since it's been some time since my initial review. If it's possible to edit your PR, I'll try to push up the requested changes to get this into an upcoming release. If not, let me know if you'll be available to finish up the PR .. no worries if you can't at this time!

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Apr 16, 2021
@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Apr 16, 2021
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

Thanks again @Stretch96 🚀 !

Output of acceptance tests:

--- SKIP: TestAccAwsServiceQuotasServiceQuota_Value_IncreaseOnCreate (0.00s)
--- SKIP: TestAccAwsServiceQuotasServiceQuota_Value_IncreaseOnUpdate (0.00s)
--- PASS: TestAccAwsServiceQuotasServiceQuotaDataSource_QuotaCode (12.99s)
--- PASS: TestAccAwsServiceQuotasServiceQuotaDataSource_QuotaName (15.00s)
--- PASS: TestAccAwsServiceQuotasServiceQuota_basic (17.13s)

@anGie44 anGie44 added enhancement Requests to existing resources that expand the functionality or scope. and removed waiting-response Maintainers are waiting on response from community or contributor. labels Apr 16, 2021
@anGie44 anGie44 added this to the v3.37.0 milestone Apr 16, 2021
@anGie44 anGie44 merged commit d25a24e into hashicorp:main Apr 16, 2021
@ghost
Copy link

ghost commented Apr 16, 2021

This has been released in version 3.37.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented May 16, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/servicequotas Issues and PRs that pertain to the servicequotas service. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_servicequotas_service_quota requires modifying tfstate if whitespace is accidently added in quota_code
2 participants