Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions internal/provider/example_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package provider
import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -23,7 +22,7 @@ func NewExampleDataSource() datasource.DataSource {

// ExampleDataSource defines the data source implementation.
type ExampleDataSource struct {
client *http.Client
data *CoderdProviderData
}

// ExampleDataSourceModel describes the data source data model.
Expand Down Expand Up @@ -60,18 +59,18 @@ func (d *ExampleDataSource) Configure(ctx context.Context, req datasource.Config
return
}

client, ok := req.ProviderData.(*http.Client)
client, ok := req.ProviderData.(*CoderdProviderData)

if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *http.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *CoderdProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
}

d.client = client
d.data = client
}

func (d *ExampleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/example_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func TestAccExampleDataSource(t *testing.T) {
}

const testAccExampleDataSourceConfig = `
provider coderd {
url = "https://dev.coder.com"
token = "iamnotarealtoken"
}

data "coderd_example" "test" {
configurable_attribute = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *UserResource) Configure(ctx context.Context, req resource.ConfigureRequ
if !ok {
resp.Diagnostics.AddError(
"Unexpected Resource Configure Type",
fmt.Sprintf("Expected *codersdk.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *CoderdProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
Expand Down