Skip to content

Commit

Permalink
fix client type
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Nov 16, 2023
1 parent 41b7e05 commit 4af1638
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions internal/datasource/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"terraform-provider-plural/internal/client"
"terraform-provider-plural/internal/model"

"github.com/hashicorp/terraform-plugin-framework/datasource"
Expand All @@ -17,7 +18,7 @@ func NewClusterDataSource() datasource.DataSource {
}

type clusterDataSource struct {
client *console.Client
client *client.Client
}

func (d *clusterDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
Expand Down Expand Up @@ -68,16 +69,16 @@ func (d *clusterDataSource) Configure(_ context.Context, req datasource.Configur
return
}

client, ok := req.ProviderData.(*console.Client)
c, ok := req.ProviderData.(*client.Client)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Cluster Resource Configure Type",
fmt.Sprintf("Expected *console.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return
}

d.client = client
d.client = c
}

func (d *clusterDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand Down
2 changes: 1 addition & 1 deletion internal/datasource/gitrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *GitRepositoryDataSource) Configure(_ context.Context, req datasource.Co
if !ok {
resp.Diagnostics.AddError(
"Unexpected GitRepository Resource Configure Type",
fmt.Sprintf("Expected *console.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
Expand Down
9 changes: 5 additions & 4 deletions internal/resource/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"terraform-provider-plural/internal/client"
"terraform-provider-plural/internal/model"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand All @@ -27,7 +28,7 @@ func NewClusterResource() resource.Resource {

// ClusterResource defines the cluster resource implementation.
type clusterResource struct {
client *console.Client
client *client.Client
}

func (r *clusterResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand Down Expand Up @@ -81,16 +82,16 @@ func (r *clusterResource) Configure(_ context.Context, req resource.ConfigureReq
return
}

client, ok := req.ProviderData.(*console.Client)
c, ok := req.ProviderData.(*client.Client)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Cluster Resource Configure Type",
fmt.Sprintf("Expected *console.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return
}

r.client = client
r.client = c
}

func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/gitrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *GitRepositoryResource) Configure(_ context.Context, req resource.Config
if !ok {
resp.Diagnostics.AddError(
"Unexpected GitRepository Resource Configure Type",
fmt.Sprintf("Expected *console.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (r *ServiceDeploymentResource) Configure(_ context.Context, req resource.Co
if !ok {
resp.Diagnostics.AddError(
"Unexpected ServiceDeployment Resource Configure Type",
fmt.Sprintf("Expected *console.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func main() {
flag.Parse()

opts := providerserver.ServeOpts{
Address: "registry.terraform.io/hashicorp/plural",
Address: "registry.terraform.io/pluralsh/plural",
Debug: debug,
}

Expand Down

0 comments on commit 4af1638

Please sign in to comment.