-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from minamijoyo/tf-1.6
Add support for Terraform v1.6
- Loading branch information
Showing
14 changed files
with
161 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package tfmigrate | ||
|
||
import "regexp" | ||
|
||
// SwitchBackToRemoteFuncError tests verify error messages, but the | ||
// error message for missing bucket key in the s3 backend differs | ||
// depending on the Terraform version. | ||
// Define a helper function to hide the difference. | ||
const testBucketRequiredErrorLegacyTF = `Error: "bucket": required field is not set` | ||
const testBucketRequiredErrorTF16 = `The attribute "bucket" is required by the backend` | ||
|
||
var testBucketRequiredErrorRE = regexp.MustCompile(testBucketRequiredErrorLegacyTF + `|` + testBucketRequiredErrorTF16) | ||
|
||
func containsBucketRequiredError(err error) bool { | ||
return testBucketRequiredErrorRE.MatchString(err.Error()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package tfmigrate | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
) | ||
|
||
func TestContainsBucketRequiredError(t *testing.T) { | ||
cases := []struct { | ||
desc string | ||
msg string | ||
want bool | ||
}{ | ||
{ | ||
desc: "terraform v1.5", | ||
msg: `Error: "bucket": required field is not set`, | ||
want: true, | ||
}, | ||
{ | ||
desc: "terraform v1.6", | ||
msg: ` | ||
Error: Missing Required Value | ||
on main.tf line 4, in terraform: | ||
4: backend "s3" { | ||
The attribute "bucket" is required by the backend. | ||
Refer to the backend documentation for additional information which | ||
attributes are required. | ||
`, | ||
want: true, | ||
}, | ||
{ | ||
desc: "unknown", | ||
msg: `Error: unknown`, | ||
want: false, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
got := containsBucketRequiredError(errors.New(tc.msg)) | ||
if got != tc.want { | ||
t.Errorf("got: %t, want: %t", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |