From a701fc4abb946fb81345a553fbdf8db48ddf0bfc Mon Sep 17 00:00:00 2001 From: Stef Forrester Date: Mon, 14 Jun 2021 16:07:46 -0700 Subject: [PATCH] Throw error when Tuple contains mixed Types Fixes https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/231 --- provider/validate.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/provider/validate.go b/provider/validate.go index c02df0b8..94af98df 100644 --- a/provider/validate.go +++ b/provider/validate.go @@ -35,6 +35,24 @@ func (s *RawProviderServer) ValidateResourceTypeConfig(ctx context.Context, req return resp, nil } + err = tftypes.Walk(config, func(path *tftypes.AttributePath, val tftypes.Value) (bool, error) { + if val.Type().Is(tftypes.Tuple{}){ + resp.Diagnostics = append(resp.Diagnostics, &tfprotov5.Diagnostic{ + Severity: tfprotov5.DiagnosticSeverityError, + Summary: "Values for Lists and Maps must be all one type. Received list with mixed types: " + val.Type().String(), + }) + } + return true, nil + }) + if err != nil { + resp.Diagnostics = append(resp.Diagnostics, &tfprotov5.Diagnostic{ + Severity: tfprotov5.DiagnosticSeverityError, + Summary: "Resource walk() failed during validation" + config.String(), + Detail: err.Error(), + }) + return resp, nil + } + att := tftypes.NewAttributePath() att = att.WithAttributeName("manifest")