Skip to content

Commit 70ed6c3

Browse files
authored
Merge pull request #54 from markliederbach/markliederbach/explicit-rules
Accept DisabledByDefault config attribute
2 parents aa9f73a + b2118b0 commit 70ed6c3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tflint/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package tflint
33
// Config is a TFLint configuration applied to the plugin.
44
// Currently, it is not expected that each plugin will reference this directly.
55
type Config struct {
6-
Rules map[string]*RuleConfig
6+
Rules map[string]*RuleConfig
7+
DisabledByDefault bool
78
}
89

910
// RuleConfig is a TFLint's rule configuration.

tflint/ruleset.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package tflint
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"log"
6+
)
47

58
// RuleSet is a list of rules that a plugin should provide.
69
type RuleSet struct {
@@ -33,10 +36,17 @@ func (r *RuleSet) RuleNames() []string {
3336
// Currently used only to enable/disable rules.
3437
func (r *RuleSet) ApplyConfig(config *Config) {
3538
rules := []Rule{}
39+
40+
if config.DisabledByDefault {
41+
log.Printf("[DEBUG] Only mode is enabled. Ignoring default plugin rules")
42+
}
43+
3644
for _, rule := range r.Rules {
3745
enabled := rule.Enabled()
3846
if cfg := config.Rules[rule.Name()]; cfg != nil {
3947
enabled = cfg.Enabled
48+
} else if config.DisabledByDefault {
49+
enabled = false
4050
}
4151

4252
if enabled {

0 commit comments

Comments
 (0)