hashicorp / hashicorp/terraform-plugin-sdk
Validate Data Sources Do Not Contain Importer Declarations
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### SDK version
```
v1.12.0
```
### Use-cases
The `helper/schema.Resource` type is shared between managed resources and data sources via the `helper/schema.Provider` type `DataSourcesMap` and `ResourcesMap` fields. When its used
as a data source, it is extraneous/invalid for the `Importer` field to be declared since data sources inherently do not support import.
### Attempted Solutions
Manual pull request review comments.
### Proposal
Enhance the provider/resource validation (performed via provider unit testing) to check if `Importer` is declared for any data sources declared via `DataSourcesMap` and return a validation failure.
### References
- https://github.com/bflad/tfproviderlint/issues/172
- https://github.com/terraform-providers/terraform-provider-aws/pull/11965
Contributor guide
Research direction
Start with the provider unit testing validation that examines DataSourcesMap and ResourcesMap, then trace how each data source's helper/schema.Resource is checked. Add coverage for a data source with Importer declared and make the validation return a failure; existing provider validation tests should confirm the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100