Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Throw error when Tuple contains mixed Types
Browse files Browse the repository at this point in the history
Fixes #231
  • Loading branch information
dak1n1 committed Jun 14, 2021
1 parent 8f80fa6 commit a701fc4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions provider/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit a701fc4

Please sign in to comment.