Skip to content

Commit

Permalink
Attempt to fix provider schema interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dgulinobw committed Jul 7, 2022
1 parent a1fd727 commit dd3d262
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=github.com
NAMESPACE=relaypro-open
NAME=dog
BINARY=terraform-provider-${NAME}
VERSION=1.0.3
VERSION=1.0.4
OS_ARCH=linux_amd64

default: install
Expand Down
15 changes: 9 additions & 6 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import (
api "github.com/relaypro-open/dog_api_golang/api"
)

// Ensure the implementation satisfies the tfsdk.Provider interface.
var _ tfsdk.Provider = &dogProvider{}

// provider satisfies the tfsdk.Provider interface and usually is included
// with all Resource and DataSource implementations.
type provider struct {
type dogProvider struct {
// client can contain the upstream provider SDK or HTTP client used to
// communicate with the upstream service. Resource and DataSource
// implementations can then make calls using this client.
Expand All @@ -39,7 +42,7 @@ type providerData struct {
API_Endpoint types.String `tfsdk:"api_endpoint"`
}

func (p *provider) Configure(ctx context.Context, req tfsdk.ConfigureProviderRequest, resp *tfsdk.ConfigureProviderResponse) {
func (p *dogProvider) Configure(ctx context.Context, req tfsdk.ConfigureProviderRequest, resp *tfsdk.ConfigureProviderResponse) {
var data providerData
diags := req.Config.Get(ctx, &data)
resp.Diagnostics.Append(diags...)
Expand Down Expand Up @@ -84,7 +87,7 @@ func (p *provider) Configure(ctx context.Context, req tfsdk.ConfigureProviderReq
p.configured = true
}

func (p *provider) GetResources(ctx context.Context) (map[string]tfsdk.ResourceType, diag.Diagnostics) {
func (p *dogProvider) GetResources(ctx context.Context) (map[string]tfsdk.ResourceType, diag.Diagnostics) {
return map[string]tfsdk.ResourceType{
"dog_host": hostResourceType{},
"dog_group": groupResourceType{},
Expand All @@ -95,7 +98,7 @@ func (p *provider) GetResources(ctx context.Context) (map[string]tfsdk.ResourceT
}, nil
}

func (p *provider) GetDataSources(ctx context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics) {
func (p *dogProvider) GetDataSources(ctx context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics) {
return map[string]tfsdk.DataSourceType{
"dog_host": hostDataSourceType{},
"dog_group": groupDataSourceType{},
Expand All @@ -106,7 +109,7 @@ func (p *provider) GetDataSources(ctx context.Context) (map[string]tfsdk.DataSou
}, nil
}

func (p *provider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (p *dogProvider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{
"api_endpoint": {
Expand All @@ -126,7 +129,7 @@ func (p *provider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostic

func New(version string) func() tfsdk.Provider {
return func() tfsdk.Provider {
return &provider{
return &dogProvider{
version: version,
}
}
Expand Down

0 comments on commit dd3d262

Please sign in to comment.