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

tfsdk: Initial support for Attribute, Data Source, Provider, and Resource validation #75

Merged
merged 18 commits into from
Aug 10, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jul 20, 2021

Reference: #17
Reference: #65

)

// DataSourceConfigValidator describes reusable DataSource configuration validation functionality.
type DataSourceConfigValidator interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hot take: is Config necessary here, or can we save some typing by removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm certainly amenable to updating the name, I'm just not sure if there's any concerns with keeping the names and types relatively close to the RPCs similar to as has been done elsewhere. Should there be any future other implementations with differing semantics, it could be weird to have DataSourceValidator vs DataSourceStateValidator for example.

tfsdk/data_source_validation.go Outdated Show resolved Hide resolved
tfsdk/data_source_validation.go Show resolved Hide resolved
tfsdk/data_source_validation.go Show resolved Hide resolved
tfsdk/data_source_validation.go Outdated Show resolved Hide resolved
tfsdk/data_source_validation.go Show resolved Hide resolved
tfsdk/request_validation.go Outdated Show resolved Hide resolved
tfsdk/serve.go Outdated Show resolved Hide resolved
tfsdk/serve.go Outdated Show resolved Hide resolved
@bflad
Copy link
Contributor Author

bflad commented Aug 2, 2021

I'm going to address the above comments and pull in the Attribute validation from #76 so it can all be reviewed together. 👍

@bflad bflad self-assigned this Aug 2, 2021
@bflad
Copy link
Contributor Author

bflad commented Aug 2, 2021

This now includes the initial Schema and Attribute validation from #76 wired together with the Validate RPC calls. It needs a test fix from the testing changing on main and unit testing for the Schema and Attribute validation. I've run out of time for today, but it might be worth a cursory look to ensure it's going in the right direction.

Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it's on the right path to me.

tfsdk/schema.go Outdated Show resolved Hide resolved
@bflad bflad requested review from paddycarver and kmoe August 6, 2021 18:07
@bflad bflad removed their assignment Aug 6, 2021
tfsdk/attribute.go Show resolved Hide resolved
tfsdk/serve.go Outdated Show resolved Hide resolved
tfsdk/serve.go Outdated Show resolved Hide resolved
tfsdk/serve.go Outdated Show resolved Hide resolved
Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work @bflad.

@bflad bflad merged commit 80104b4 into main Aug 10, 2021
@bflad bflad deleted the f-validation branch August 10, 2021 14:03
@bflad bflad changed the title tfsdk: Initial support for Data Source, Provider, and Resource validation tfsdk: Initial support for Attribute, Data Source, Provider, and Resource validation Aug 10, 2021
@bflad bflad added this to the v0.3.0 milestone Aug 10, 2021
@bflad bflad mentioned this pull request Aug 10, 2021

attribute.validate(ctx, attributeReq, attributeResp)

resp.Diagnostics = attributeResp.Diagnostics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this append instead, in case multiple attribute validators return warning diags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially this was appending, but I was asked to switch it to "passthrough" diagnostics: #75 (comment)

Personally I think pre-populating a response, while offering overwrite capabilities easily, could be confusing for implementors to understand the semantics. We could offer prior diagnostics in the request with diagnostic modifications in the response to clarify things on both sides of these calls (or not allow diagnostic modification). Please let me know if you would like me to raise an issue regarding this.

@paddycarver paddycarver mentioned this pull request Aug 16, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants