Skip to content

Commit

Permalink
feat: rule names (#15)
Browse files Browse the repository at this point in the history
* feat: modify rule names to be more predictable

* feat: make rule names generic

* test: fix integration
  • Loading branch information
matt-FFFFFF authored Mar 29, 2024
1 parent 5db50b4 commit 9bbf595
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions attrvalue/set_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func NewSetRule[T cmp.Ordered](resourceType string, attributeName string, expect

func (r *SetRule[T]) Name() string {
if r.nestedBlockType != nil {
return fmt.Sprintf("%s.%s.%s_must_be_%+v", r.resourceType, *r.nestedBlockType, r.attributeName, r.expectedValues)
return fmt.Sprintf("set_value_%s.%s.%s", r.resourceType, *r.nestedBlockType, r.attributeName)
}
return fmt.Sprintf("%s.%s_must_be_%v", r.resourceType, r.attributeName, r.expectedValues)
return fmt.Sprintf("set_value_%s.%s", r.resourceType, r.attributeName)
}

func (r *SetRule[T]) Check(runner tflint.Runner) error {
Expand Down
4 changes: 2 additions & 2 deletions attrvalue/simple_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (r *SimpleRule[T]) Link() string {

func (r *SimpleRule[T]) Name() string {
if r.nestedBlockType != nil {
return fmt.Sprintf("%s.%s.%s_must_be_%+v", r.resourceType, *r.nestedBlockType, r.attributeName, r.expectedValues)
return fmt.Sprintf("simple_value_%s.%s.%s", r.resourceType, *r.nestedBlockType, r.attributeName)
}
return fmt.Sprintf("%s.%s_must_be_%+v", r.resourceType, r.attributeName, r.expectedValues)
return fmt.Sprintf("simple_value_%s.%s", r.resourceType, r.attributeName)
}

func (r *SimpleRule[T]) Check(runner tflint.Runner) error {
Expand Down
4 changes: 2 additions & 2 deletions attrvalue/unknown_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func NewUnknownValueNestedBlockRule(resourceType, nestedBlockType, attributeName

func (r *UnknownValueRule) Name() string {
if r.nestedBlockType != nil {
return fmt.Sprintf("%s.%s.%s_must_be_unknown", r.resourceType, *r.nestedBlockType, r.attributeName)
return fmt.Sprintf("unknown_value_%s.%s.%s", r.resourceType, *r.nestedBlockType, r.attributeName)
}
return fmt.Sprintf("%s.%s_must_be_unknown", r.resourceType, r.attributeName)
return fmt.Sprintf("unknown_value_%s.%s", r.resourceType, r.attributeName)
}

func (r *UnknownValueRule) Check(runner tflint.Runner) error {
Expand Down
2 changes: 1 addition & 1 deletion integration/optional-defaults-incorrect/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"rule": {
"link": "https://azure.github.io/Azure-Proactive-Resiliency-Library/services/networking/load-balancer/#lb-1---use-standard-load-balancer-sku",
"name": "azurerm_lb.sku_must_be_[Standard]",
"name": "simple_value_azurerm_lb.sku",
"severity": "error"
}
}
Expand Down
2 changes: 1 addition & 1 deletion integration/unknownrule-null-incorrect/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"rule": {
"link": "https://azure.github.io/Azure-Proactive-Resiliency-Library/services/compute/virtual-machines/#vm-2---deploy-vms-across-availability-zones",
"name": "azurerm_virtual_machine.zone_must_be_unknown",
"name": "unknown_value_azurerm_virtual_machine.zone",
"severity": "error"
}
}
Expand Down

0 comments on commit 9bbf595

Please sign in to comment.