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

s3_bucket_name: add all documented naming rules #571

Merged
merged 2 commits into from
Nov 11, 2023

Conversation

davimmt
Copy link
Contributor

@davimmt davimmt commented Nov 6, 2023

From this discussion.

Also an alternative to remove hardcoded values from this past issue.

@bendrucker bendrucker self-requested a review November 6, 2023 19:32
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
rules/aws_s3_bucket_name.go Outdated Show resolved Hide resolved
@davimmt
Copy link
Contributor Author

davimmt commented Nov 7, 2023

If everything's OK, I'll only need to write a test for each item in aws_s3_bucket_name_test.go. These changes requires additional testing in integration/ too?

@bendrucker
Copy link
Member

Unit testing this rule should be fine, no integration tests needed.

@@ -81,7 +81,7 @@ func (r *AwsS3BucketNameRule) Check(runner tflint.Runner) error {
}{
{
Regexp: *regexp.MustCompile(fmt.Sprintf(
"^(.{0,%d})?(.{%d,})?$",
"^.{0,%d}$|.{%d,}$",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found out about the alternation operator in Go and thought it was easier to read and more go-friendly.

Comment on lines +99 to +100
Regexp: *regexp.MustCompile("^[^a-z0-9]|[^a-z0-9]$"),
Description: "Bucket names must begin and end with a lowercase letter or number.",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The alternation operator could also be used here to merge these two rules in one, just as the docs.

@bendrucker bendrucker self-requested a review November 8, 2023 01:10
@bendrucker
Copy link
Member

Thanks! Will do another review and edit as needed later this week.

@bendrucker bendrucker merged commit f27e23d into terraform-linters:master Nov 11, 2023
8 checks passed
@bendrucker bendrucker changed the title s3_bucket_name: add validations s3_bucket_name: add all documented naming rules Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants