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

New Extra Check: Schema Elem should be *schema.Schema or *schema.Resource #174

Open
bflad opened this issue May 29, 2020 · 0 comments
Open
Labels
ast AST Handling check/schema Schema Check new-check New Lint Check

Comments

@bflad
Copy link
Owner

bflad commented May 29, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

While a helper/schema.Schema.Elem may contain a schema.ValueType Go type in some very limited cases (e.g. root TypeMap attributes), its support is limited, its not implemented in many providers, and otherwise can cause a panic in the Terraform Plugin SDK:

panic: invalid element type: schema.ValueType

For consistency and safety, a new extra check can recommend the more common &schema.Schema{Type: /* ... */} implementation.

New Checks

  • XS###

Flagged Provider Code

&schema.Schema{
  Type: schema.TypeList,
  Elem: schema.TypeString,
}

Passing Provider Code

&schema.Schema{
  Type: schema.TypeList,
  Elem: &schema.Schema{
    Type: schema.TypeString,
  },
}

References

@bflad bflad added ast AST Handling new-check New Lint Check check/schema Schema Check labels May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast AST Handling check/schema Schema Check new-check New Lint Check
Projects
None yet
Development

No branches or pull requests

1 participant