Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cmd/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type Options struct {
EnablePlugins []string `long:"enable-plugin" description:"Enable plugins from the command line" value-name:"PLUGIN_NAME"`
Varfiles []string `long:"var-file" description:"Terraform variable file name" value-name:"FILE"`
Variables []string `long:"var" description:"Set a Terraform variable" value-name:"'foo=bar'"`
Module *bool `long:"module" description:"Inspect modules"`
Module *bool `long:"module" description:"Enable module inspection"`
NoModule *bool `long:"no-module" description:"Disable module inspection"`
Chdir string `long:"chdir" description:"Switch to a different working directory before executing the command" value-name:"DIR"`
Recursive bool `long:"recursive" description:"Run command in each directory recursively"`
Filter []string `long:"filter" description:"Filter issues by file names or globs" value-name:"FILE"`
Expand Down Expand Up @@ -51,19 +52,17 @@ func (opts *Options) toConfig() *tflint.Config {
}

var module, moduleSet bool
if opts.Module == nil {
module = false
moduleSet = false
} else {
if opts.Module != nil {
module = *opts.Module
moduleSet = true
}
if opts.NoModule != nil {
module = !*opts.NoModule
moduleSet = true
}

var force, forceSet bool
if opts.Force == nil {
force = false
forceSet = false
} else {
if opts.Force != nil {
force = *opts.Force
forceSet = true
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ func Test_toConfig(t *testing.T) {
Plugins: map[string]*tflint.PluginConfig{},
},
},
{
Name: "--no-module",
Command: "./tflint --no-module",
Expected: &tflint.Config{
Module: false,
ModuleSet: true,
Force: false,
IgnoreModules: map[string]bool{},
Varfiles: []string{},
Variables: []string{},
DisabledByDefault: false,
Rules: map[string]*tflint.RuleConfig{},
Plugins: map[string]*tflint.PluginConfig{},
},
},
{
Name: "--force",
Command: "./tflint --force",
Expand Down