Skip to content

Commit

Permalink
plugin: Drop support for bundled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Mar 20, 2022
1 parent 10c116e commit b5fee80
Show file tree
Hide file tree
Showing 57 changed files with 296 additions and 527 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ build:
install:
go install

e2e: prepare install
go test -timeout 5m ./integrationtest/inspection ./integrationtest/langserver ./integrationtest/bundled ./integrationtest/init
e2e: prepare
go test -timeout 5m ./integrationtest/inspection ./integrationtest/langserver ./integrationtest/init

lint:
golangci-lint run ./...
Expand Down
2 changes: 0 additions & 2 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ func (cli *CLI) Run(args []string) int {
return cli.init(opts)
case opts.Langserver:
return cli.startLanguageServer(opts.Config, opts.toConfig())
case opts.ActAsAwsPlugin:
return cli.actAsAwsPlugin()
default:
return cli.inspect(opts, dir, filterFiles)
}
Expand Down
20 changes: 0 additions & 20 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"log"

"github.com/spf13/afero"
tfplugin "github.com/terraform-linters/tflint/plugin"
Expand Down Expand Up @@ -41,25 +40,6 @@ func (cli *CLI) inspect(opts Options, dir string, filterFiles []string) int {
}
rootRunner := runners[len(runners)-1]

// AWS plugin is automatically enabled from your provider requirements, even if the plugin isn't explicitly enabled.
if _, exists := cfg.Plugins["aws"]; !exists {
reqs, diags := rootRunner.TFConfig.ProviderRequirements()
if diags.HasErrors() {
cli.formatter.Print(tflint.Issues{}, tflint.NewContextError("Failed to get Terraform provider requirements", diags), cli.loader.Sources())
return ExitCodeError
}
for addr := range reqs {
if addr.Type == "aws" {
log.Print("[INFO] AWS provider requirements found. Enable the plugin `aws` automatically")
fmt.Fprintln(cli.errStream, "WARNING: The plugin `aws` is not explicitly enabled. The bundled plugin will be enabled instead, but it is deprecated and will be removed in a future version. Please see https://github.com/terraform-linters/tflint/pull/1160 for details.")
cfg.Plugins["aws"] = &tflint.PluginConfig{
Name: "aws",
Enabled: true,
}
}
}
}

// Lookup plugins and validation
plugin, err := tfplugin.Discovery(cfg)
if err != nil {
Expand Down
27 changes: 0 additions & 27 deletions cmd/internal_aws_plugin.go

This file was deleted.

33 changes: 16 additions & 17 deletions cmd/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ import (

// Options is an option specified by arguments.
type Options struct {
Version bool `short:"v" long:"version" description:"Print TFLint version"`
Init bool `long:"init" description:"Install plugins"`
Langserver bool `long:"langserver" description:"Start language server"`
Format string `short:"f" long:"format" description:"Output format" choice:"default" choice:"json" choice:"checkstyle" choice:"junit" choice:"compact" choice:"sarif" default:"default"`
Config string `short:"c" long:"config" description:"Config file name" value-name:"FILE" default:".tflint.hcl"`
IgnoreModules []string `long:"ignore-module" description:"Ignore module sources" value-name:"SOURCE"`
EnableRules []string `long:"enable-rule" description:"Enable rules from the command line" value-name:"RULE_NAME"`
DisableRules []string `long:"disable-rule" description:"Disable rules from the command line" value-name:"RULE_NAME"`
Only []string `long:"only" description:"Enable only this rule, disabling all other defaults. Can be specified multiple times" value-name:"RULE_NAME"`
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"`
Force bool `long:"force" description:"Return zero exit status even if issues found"`
NoColor bool `long:"no-color" description:"Disable colorized output"`
LogLevel string `long:"loglevel" description:"Change the loglevel" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error"`
ActAsAwsPlugin bool `long:"act-as-aws-plugin" hidden:"true"`
Version bool `short:"v" long:"version" description:"Print TFLint version"`
Init bool `long:"init" description:"Install plugins"`
Langserver bool `long:"langserver" description:"Start language server"`
Format string `short:"f" long:"format" description:"Output format" choice:"default" choice:"json" choice:"checkstyle" choice:"junit" choice:"compact" choice:"sarif" default:"default"`
Config string `short:"c" long:"config" description:"Config file name" value-name:"FILE" default:".tflint.hcl"`
IgnoreModules []string `long:"ignore-module" description:"Ignore module sources" value-name:"SOURCE"`
EnableRules []string `long:"enable-rule" description:"Enable rules from the command line" value-name:"RULE_NAME"`
DisableRules []string `long:"disable-rule" description:"Disable rules from the command line" value-name:"RULE_NAME"`
Only []string `long:"only" description:"Enable only this rule, disabling all other defaults. Can be specified multiple times" value-name:"RULE_NAME"`
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"`
Force bool `long:"force" description:"Return zero exit status even if issues found"`
NoColor bool `long:"no-color" description:"Disable colorized output"`
LogLevel string `long:"loglevel" description:"Change the loglevel" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error"`
}

func (opts *Options) toConfig() *tflint.Config {
Expand Down
33 changes: 0 additions & 33 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"

"github.com/spf13/afero"
tfplugin "github.com/terraform-linters/tflint/plugin"
"github.com/terraform-linters/tflint/tflint"
)
Expand All @@ -25,38 +24,6 @@ func (cli *CLI) printVersion(opts Options) int {
}
cfg = cfg.Merge(opts.toConfig())

cli.loader, err = tflint.NewLoader(afero.Afero{Fs: afero.NewOsFs()}, cfg)
if err != nil {
log.Printf("[ERROR] Failed to prepare loading: %s", err)
return ExitCodeOK
}

runners, appErr := cli.setupRunners(opts, cfg, ".")
if appErr != nil {
log.Printf("[ERROR] Failed to setup runners: %s", appErr)
return ExitCodeOK
}
rootRunner := runners[len(runners)-1]

// AWS plugin is automatically enabled from your provider requirements, even if the plugin isn't explicitly enabled.
if _, exists := cfg.Plugins["aws"]; !exists {
reqs, diags := rootRunner.TFConfig.ProviderRequirements()
if diags.HasErrors() {
log.Printf("[ERROR] Failed to get Terraform provider requirements: %s", diags)
return ExitCodeOK
}
for addr := range reqs {
if addr.Type == "aws" {
log.Print("[INFO] AWS provider requirements found. Enable the plugin `aws` automatically")
fmt.Fprintln(cli.errStream, "WARNING: The plugin `aws` is not explicitly enabled. The bundled plugin will be enabled instead, but it is deprecated and will be removed in a future version. Please see https://github.com/terraform-linters/tflint/pull/1160 for details.")
cfg.Plugins["aws"] = &tflint.PluginConfig{
Name: "aws",
Enabled: true,
}
}
}
}

plugin, err := tfplugin.Discovery(cfg)
if err != nil {
log.Printf("[ERROR] Failed to initialize plugins: %s", err)
Expand Down
3 changes: 0 additions & 3 deletions integrationtest/bundled/basic/template.tf

This file was deleted.

150 changes: 0 additions & 150 deletions integrationtest/bundled/bundled_test.go

This file was deleted.

4 changes: 0 additions & 4 deletions integrationtest/bundled/cty-based-eval/.tflint.hcl

This file was deleted.

25 changes: 0 additions & 25 deletions integrationtest/bundled/cty-based-eval/result.json

This file was deleted.

7 changes: 0 additions & 7 deletions integrationtest/bundled/cty-based-eval/template.tf

This file was deleted.

7 changes: 0 additions & 7 deletions integrationtest/bundled/deep-checking-rule-config/.tflint.hcl

This file was deleted.

4 changes: 0 additions & 4 deletions integrationtest/bundled/deep-checking-rule-config/result.json

This file was deleted.

11 changes: 0 additions & 11 deletions integrationtest/bundled/disabled-rules/.tflint.hcl

This file was deleted.

7 changes: 0 additions & 7 deletions integrationtest/bundled/disabled-rules/template.tf

This file was deleted.

Loading

0 comments on commit b5fee80

Please sign in to comment.