Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log at INFO level when TFLint cannot statically evaluate an expression #1113

Merged
merged 3 commits into from
Apr 30, 2021
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
4 changes: 2 additions & 2 deletions plugin/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/terraform-linters/tflint-plugin-sdk/terraform/configs"
"github.com/terraform-linters/tflint-plugin-sdk/terraform/experiments"
tfplugin "github.com/terraform-linters/tflint-plugin-sdk/tflint/client"
"github.com/zclconf/go-cty/cty/msgpack"
"github.com/zclconf/go-cty/cty/json"
"github.com/terraform-linters/tflint/tflint"
"github.com/zclconf/go-cty/cty/json"
"github.com/zclconf/go-cty/cty/msgpack"
)

func (s *Server) encodeConfig(config *tfconfigs.Config) (*tfplugin.Config, error) {
Expand Down
20 changes: 10 additions & 10 deletions plugin/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func Test_EvalExpr_errors(t *testing.T) {
expected := client.Error{
Code: client.UnknownValueError,
Level: client.WarningLevel,
Message: "Unknown value found in template.tf:1; Please use environment variables or tfvars to set the value",
Message: "Unknown value found in template.tf:1",
Cause: nil,
}
if !cmp.Equal(expected, resp.Err) {
Expand Down Expand Up @@ -410,20 +410,20 @@ resource "aws_s3_bucket" "bar" {

expected := &tfplugin.Config{
Module: &tfplugin.Module{
SourceDir: ".",
CoreVersionConstraints: []string{},
SourceDir: ".",
CoreVersionConstraints: []string{},
CoreVersionConstraintRanges: []hcl.Range{},
ActiveExperiments: experiments.Set{},
ProviderConfigs: map[string]*tfplugin.Provider{},
ActiveExperiments: experiments.Set{},
ProviderConfigs: map[string]*tfplugin.Provider{},
ProviderRequirements: &tfplugin.RequiredProviders{
RequiredProviders: map[string]*tfplugin.RequiredProvider{},
},
ProviderLocalNames: map[addrs.Provider]string{},
ProviderMetas: map[addrs.Provider]*tfplugin.ProviderMeta{},
Variables: map[string]*tfplugin.Variable{},
Locals: map[string]*tfplugin.Local{},
Outputs: map[string]*tfplugin.Output{},
ModuleCalls: map[string]*tfplugin.ModuleCall{},
ProviderMetas: map[addrs.Provider]*tfplugin.ProviderMeta{},
Variables: map[string]*tfplugin.Variable{},
Locals: map[string]*tfplugin.Local{},
Outputs: map[string]*tfplugin.Output{},
ModuleCalls: map[string]*tfplugin.ModuleCall{},
ManagedResources: map[string]*tfplugin.Resource{
"aws_instance.foo": {
Mode: addrs.ManagedResourceMode,
Expand Down
10 changes: 5 additions & 5 deletions tflint/runner_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (r *Runner) EvalExpr(expr hcl.Expression, ret interface{}, wantType cty.Typ
expr.Range().Start.Line,
),
}
log.Printf("[WARN] %s. TFLint ignores unevaluable expressions.", err)
log.Printf("[INFO] %s. TFLint ignores unevaluable expressions.", err)
return cty.NullVal(cty.NilType), err
}

Expand Down Expand Up @@ -120,7 +120,7 @@ func (r *Runner) EvalExpr(expr hcl.Expression, ret interface{}, wantType cty.Typ
expr.Range().Start.Line,
),
}
log.Printf("[WARN] %s. TFLint can only evaluate provided variables and skips dynamic values.", err)
log.Printf("[INFO] %s. TFLint can only evaluate provided variables and skips dynamic values.", err)
return false, err
}

Expand All @@ -134,7 +134,7 @@ func (r *Runner) EvalExpr(expr hcl.Expression, ret interface{}, wantType cty.Typ
expr.Range().Start.Line,
),
}
log.Printf("[WARN] %s. TFLint ignores expressions with null values.", err)
log.Printf("[INFO] %s. TFLint ignores expressions with null values.", err)
return false, err
}

Expand Down Expand Up @@ -176,7 +176,7 @@ func (r *Runner) EvaluateBlock(block *hcl.Block, schema *configschema.Block, ret
block.DefRange.Start.Line,
),
}
log.Printf("[WARN] %s. TFLint ignores unevaluable blocks.", err)
log.Printf("[INFO] %s. TFLint ignores unevaluable blocks.", err)
return err
}

Expand Down Expand Up @@ -207,7 +207,7 @@ func (r *Runner) EvaluateBlock(block *hcl.Block, schema *configschema.Block, ret
block.DefRange.Start.Line,
),
}
log.Printf("[WARN] %s. TFLint can only evaluate provided variables and skips blocks with unknown values.", err)
log.Printf("[INFO] %s. TFLint can only evaluate provided variables and skips blocks with unknown values.", err)
return false, err
}

Expand Down
6 changes: 3 additions & 3 deletions tflint/runner_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ resource "null_resource" "test" {
Error: Error{
Code: UnknownValueError,
Level: WarningLevel,
Message: "Unknown value found in main.tf:5; Please use environment variables or tfvars to set the value",
Message: "Unknown value found in main.tf:5",
},
},
{
Expand Down Expand Up @@ -552,7 +552,7 @@ resource "null_resource" "test" {
Error: Error{
Code: UnknownValueError,
Level: WarningLevel,
Message: "Unknown value found in main.tf:5; Please use environment variables or tfvars to set the value",
Message: "Unknown value found in main.tf:5",
},
},
{
Expand Down Expand Up @@ -719,7 +719,7 @@ resource "null_resource" "test" {
Error: Error{
Code: UnknownValueError,
Level: WarningLevel,
Message: "Unknown value found in main.tf:5; Please use environment variables or tfvars to set the value",
Message: "Unknown value found in main.tf:5",
},
},
{
Expand Down