Skip to content

Commit

Permalink
Add warnings to --module/--no-module and module attribute (#1951)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Apr 30, 2024
1 parent 3802c92 commit 0c0f631
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/option.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cmd

import (
"fmt"
"log"
"os"
"strings"

"github.com/terraform-linters/tflint/terraform"
Expand Down Expand Up @@ -59,10 +61,12 @@ func (opts *Options) toConfig() *tflint.Config {
callModuleTypeSet := false
// --call-module-type takes precedence over --module/--no-module. This is for backward compatibility.
if opts.Module != nil {
fmt.Fprintln(os.Stderr, "WARNING: --module is deprecated. Use --call-module-type=all instead.")
callModuleType = terraform.CallAllModule
callModuleTypeSet = true
}
if opts.NoModule != nil {
fmt.Fprintln(os.Stderr, "WARNING: --no-module is deprecated. Use --call-module-type=none instead.")
callModuleType = terraform.CallNoModule
callModuleTypeSet = true
}
Expand Down
1 change: 1 addition & 0 deletions tflint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func loadConfig(file afero.File) (*Config, error) {
// "module" attribute is deprecated. Use "call_module_type" instead.
// This is for backward compatibility.
case "module":
fmt.Fprintf(os.Stderr, "WARNING: \"module\" attribute in %s is deprecated. Use \"call_module_type\" instead.\n", file.Name())
if config.CallModuleTypeSet {
// If "call_module_type" is set, ignore "module" attribute
continue
Expand Down

0 comments on commit 0c0f631

Please sign in to comment.