From 65523ce3048579d7af1e55731f87c5ae00a0305a Mon Sep 17 00:00:00 2001 From: Craig Squire <677724+csquire@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:27:07 -0600 Subject: [PATCH] Improve checking in Configure method --- .../objects/azure_dev_ops_project/data_source.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/framework/objects/azure_dev_ops_project/data_source.go b/pkg/framework/objects/azure_dev_ops_project/data_source.go index 3abfb87..5fe0e5b 100644 --- a/pkg/framework/objects/azure_dev_ops_project/data_source.go +++ b/pkg/framework/objects/azure_dev_ops_project/data_source.go @@ -64,11 +64,16 @@ func (d *azureDevOpsProjectDataSource) Read( func (d *azureDevOpsProjectDataSource) Configure( _ context.Context, req datasource.ConfigureRequest, - _ *datasource.ConfigureResponse, + resp *datasource.ConfigureResponse, ) { - if req.ProviderData == nil { - return + switch c := req.ProviderData.(type) { + case nil: // do nothing + case *dbt_cloud.Client: + d.client = c + default: + resp.Diagnostics.AddError( + "Missing client", + "A client is required to configure the Azure DevOps Project data source", + ) } - - d.client = req.ProviderData.(*dbt_cloud.Client) }