generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add location interface * fix: forgot to add interface to Rules slice * fix: remove unused func * chore: update link * refactor getAttr function, extract attribute non-existance check logic into new function attributeNotExist (#19) --------- Co-authored-by: lonegunmanb <lonegunmanb@hotmail.com>
- Loading branch information
1 parent
9bbf595
commit 61f6cc4
Showing
6 changed files
with
177 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package interfaces | ||
|
||
import ( | ||
"github.com/matt-FFFFFF/tfvarcheck/varcheck" | ||
"github.com/terraform-linters/tflint-plugin-sdk/tflint" | ||
"github.com/zclconf/go-cty/cty" | ||
) | ||
|
||
var LocationTypeString = `string` | ||
|
||
var locationType = StringToTypeConstraintWithDefaults(LocationTypeString) | ||
|
||
var Location = AvmInterface{ | ||
VarCheck: varcheck.NewVarCheck(locationType, cty.UnknownVal(cty.String), false), | ||
RuleName: "location", | ||
VarTypeString: LocationTypeString, | ||
RuleEnabled: true, | ||
RuleLink: "https://azure.github.io/Azure-Verified-Modules/specs/shared/#id-rmnfr2---category-inputs---parametervariable-naming", | ||
RuleSeverity: tflint.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,45 @@ | ||
package interfaces_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Azure/tflint-ruleset-avm/interfaces" | ||
"github.com/terraform-linters/tflint-plugin-sdk/helper" | ||
) | ||
|
||
// TestLockTerraformVar tests Lock interface. | ||
func TestTerraformLocationInterface(t *testing.T) { | ||
cases := []struct { | ||
Name string | ||
Content string | ||
JSON bool | ||
Expected helper.Issues | ||
}{ | ||
{ | ||
Name: "correct", | ||
Content: toTerraformVarType(interfaces.Location), | ||
Expected: helper.Issues{}, | ||
}, | ||
} | ||
|
||
rule := interfaces.NewVarCheckRuleFromAvmInterface(interfaces.Location) | ||
|
||
for _, tc := range cases { | ||
tc := tc | ||
t.Run(tc.Name, func(t *testing.T) { | ||
t.Parallel() | ||
filename := "variables.tf" | ||
if tc.JSON { | ||
filename += ".json" | ||
} | ||
|
||
runner := helper.TestRunner(t, map[string]string{filename: tc.Content}) | ||
|
||
if err := rule.Check(runner); err != nil { | ||
t.Fatalf("Unexpected error occurred: %s", err) | ||
} | ||
|
||
helper.AssertIssuesWithoutRange(t, tc.Expected, runner.Issues) | ||
}) | ||
} | ||
} |