From 9d50e387844f217a2c493d2bead47d09ea7e68fb Mon Sep 17 00:00:00 2001 From: wata_mac Date: Sat, 20 Mar 2021 15:54:30 +0900 Subject: [PATCH] Pass only type to EvalExpr when passed detailed types --- tflint/client/client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tflint/client/client.go b/tflint/client/client.go index c0b8751..2e5b985 100644 --- a/tflint/client/client.go +++ b/tflint/client/client.go @@ -246,7 +246,10 @@ func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}, wantType *ct } var response EvalExprResponse - req := EvalExprRequest{Ret: ret, Type: *wantType} + req := EvalExprRequest{Type: *wantType} + if req.Type == (cty.Type{}) { + req.Ret = ret + } req.Expr, req.ExprRange = encodeExpr(file.Bytes, expr) if err := c.rpcClient.Call("Plugin.EvalExpr", req, &response); err != nil { return err @@ -285,7 +288,10 @@ func (c *Client) EvaluateExprOnRootCtx(expr hcl.Expression, ret interface{}, wan } var response EvalExprResponse - req := EvalExprRequest{Ret: ret, Type: *wantType} + req := EvalExprRequest{Type: *wantType} + if req.Type == (cty.Type{}) { + req.Ret = ret + } req.Expr, req.ExprRange = encodeExpr(file.Bytes, expr) if err := c.rpcClient.Call("Plugin.EvalExprOnRootCtx", req, &response); err != nil { return err