From d88ef0ebd25497979c7d51411f2677fa0c5f03e0 Mon Sep 17 00:00:00 2001 From: Benjamin Bennett Date: Wed, 13 Mar 2024 12:49:13 +0000 Subject: [PATCH] Add clarification for nil check of ProviderData in data source and resource Configure() method (#951) --- website/docs/plugin/framework/data-sources/configure.mdx | 3 ++- website/docs/plugin/framework/resources/configure.mdx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/website/docs/plugin/framework/data-sources/configure.mdx b/website/docs/plugin/framework/data-sources/configure.mdx index 51f8c37b8..729f887e0 100644 --- a/website/docs/plugin/framework/data-sources/configure.mdx +++ b/website/docs/plugin/framework/data-sources/configure.mdx @@ -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 } diff --git a/website/docs/plugin/framework/resources/configure.mdx b/website/docs/plugin/framework/resources/configure.mdx index 5e05acad8..5cb3f9b3e 100644 --- a/website/docs/plugin/framework/resources/configure.mdx +++ b/website/docs/plugin/framework/resources/configure.mdx @@ -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 }