Skip to content

Commit

Permalink
Add clarification for nil check of ProviderData in data source and re…
Browse files Browse the repository at this point in the history
…source Configure() method (#951)
  • Loading branch information
bendbennett authored Mar 13, 2024
1 parent c2c3dda commit d88ef0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion website/docs/plugin/framework/data-sources/configure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type ThingDataSource struct {
}

func (d *ThingDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
// Prevent panic if the provider has not been configured.
// A nil check should always be performed when handling ProviderData as it
// is only set after the ConfigureProvider RPC has been called by Terraform.
if req.ProviderData == nil {
return
}
Expand Down
3 changes: 2 additions & 1 deletion website/docs/plugin/framework/resources/configure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type ThingResource struct {
}

func (r *ThingResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
// Prevent panic if the provider has not been configured.
// A nil check should always be performed when handling ProviderData as it
// is only set after the ConfigureProvider RPC has been called by Terraform.
if req.ProviderData == nil {
return
}
Expand Down

0 comments on commit d88ef0e

Please sign in to comment.