-
Notifications
You must be signed in to change notification settings - Fork 14
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
Modify regex to detect other legitimate forms of provider block declaration #265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me 🚀
internal/teststep/config.go
Outdated
@@ -21,7 +21,7 @@ const ( | |||
) | |||
|
|||
var ( | |||
providerConfigBlockRegex = regexp.MustCompile(`provider "?[a-zA-Z0-9_-]+"? {`) | |||
providerConfigBlockRegex = regexp.MustCompile(`provider(\s*"[a-zA-Z0-9_-]+"\s*|\s+[a-zA-Z0-9_-]+\s*){`) | |||
terraformConfigBlockRegex = regexp.MustCompile(`terraform {`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I presume the same whitespace problem can occur with terraform{
as well, although terraform validate
may not raise an error and Terraform may instead merge the terraform
configuration block... configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I can verify that having duplicate terraform
blocks can lead to issues. For example:
Error: Duplicate required providers configuration
on terraform_plugin_test.tf line 13, in terraform:
13: required_providers {
A module may have only one required providers configuration. The required
providers were previously configured at terraform_plugin_test.tf:3,3-21.
testing_new.go:80: Error retrieving state, there may be dangling resources: exit status 1
Have modified the regex for detection of terraform
block, and updated the tests.
Co-authored-by: Brian Flad <bflad417@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome! 🚀
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes: #264