Skip to content

Commit

Permalink
Check cloud configuration and check to ensure that the datasource imp…
Browse files Browse the repository at this point in the history
…lements the interfaces (#1999)
  • Loading branch information
spinillos authored Jan 22, 2025
1 parent b693f04 commit 1c9315d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/resources/cloud/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func (r *basePluginFrameworkDataSource) Configure(ctx context.Context, req datas
return
}

if client.GrafanaCloudAPI == nil {
resp.Diagnostics.AddError(
"The Grafana Provider is missing a configuration for the Grafana Cloud API.",
"Please ensure that cloud_api_url and cloud_access_policy_token are set in the provider configuration.",
)

return
}

r.client = client.GrafanaCloudAPI
}

Expand Down
3 changes: 3 additions & 0 deletions internal/resources/cloud/data_source_cloud_access_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

var _ datasource.DataSource = &AccessPoliciesDataSource{}
var _ datasource.DataSourceWithConfigure = &AccessPoliciesDataSource{}

var dataSourceAccessPoliciesName = "grafana_cloud_access_policies"

func datasourceAccessPolicies() *common.DataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

var _ datasource.DataSource = &PDCNetworksDataSource{}
var _ datasource.DataSourceWithConfigure = &PDCNetworksDataSource{}

var dataSourcePrivateDataSourceConnectNetworksName = "grafana_cloud_private_data_source_connect_networks"

func datasourcePrivateDataSourceConnectNetworks() *common.DataSource {
Expand Down

0 comments on commit 1c9315d

Please sign in to comment.