Skip to content

Commit

Permalink
internal/registry: New Go packages: hashicorp/terraform-plugin-framew…
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Aug 18, 2022
1 parent 61c8805 commit fc66f6b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/registry/registry.go
Expand Up @@ -4,19 +4,19 @@ import (
"context"
"sync"

"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/provider"
)

var dataSourceRegisrationClosed bool
var dataSourceRegistry map[string]func(context.Context) (tfsdk.DataSourceType, error)
var dataSourceRegistry map[string]func(context.Context) (provider.DataSourceType, error)
var dataSourceRegistryMu sync.Mutex

var resourceRegisrationClosed bool
var resourceRegistry map[string]func(context.Context) (tfsdk.ResourceType, error)
var resourceRegistry map[string]func(context.Context) (provider.ResourceType, error)
var resourceRegistryMu sync.Mutex

// AddDataSourceTypeFactory registers the specified data source type name and factory.
func AddDataSourceTypeFactory(name string, factory func(context.Context) (tfsdk.DataSourceType, error)) {
func AddDataSourceTypeFactory(name string, factory func(context.Context) (provider.DataSourceType, error)) {
dataSourceRegistryMu.Lock()
defer dataSourceRegistryMu.Unlock()

Expand All @@ -25,13 +25,13 @@ func AddDataSourceTypeFactory(name string, factory func(context.Context) (tfsdk.
}

if dataSourceRegistry == nil {
dataSourceRegistry = make(map[string]func(context.Context) (tfsdk.DataSourceType, error))
dataSourceRegistry = make(map[string]func(context.Context) (provider.DataSourceType, error))
}
dataSourceRegistry[name] = factory
}

// AddResourceTypeFactory registers the specified resource type name and factory.
func AddResourceTypeFactory(name string, factory func(context.Context) (tfsdk.ResourceType, error)) {
func AddResourceTypeFactory(name string, factory func(context.Context) (provider.ResourceType, error)) {
resourceRegistryMu.Lock()
defer resourceRegistryMu.Unlock()

Expand All @@ -40,14 +40,14 @@ func AddResourceTypeFactory(name string, factory func(context.Context) (tfsdk.Re
}

if resourceRegistry == nil {
resourceRegistry = make(map[string]func(context.Context) (tfsdk.ResourceType, error))
resourceRegistry = make(map[string]func(context.Context) (provider.ResourceType, error))
}
resourceRegistry[name] = factory
}

// ResourceFactories returns the registered resource factories.
// Resource registration is closed.
func ResourceFactories() map[string]func(context.Context) (tfsdk.ResourceType, error) {
func ResourceFactories() map[string]func(context.Context) (provider.ResourceType, error) {
resourceRegistryMu.Lock()
defer resourceRegistryMu.Unlock()

Expand All @@ -58,7 +58,7 @@ func ResourceFactories() map[string]func(context.Context) (tfsdk.ResourceType, e

// DataSourceFactories returns the registered data source factories.
// Data Source registration is closed.
func DataSourceFactories() map[string]func(context.Context) (tfsdk.DataSourceType, error) {
func DataSourceFactories() map[string]func(context.Context) (provider.DataSourceType, error) {
dataSourceRegistryMu.Lock()
defer dataSourceRegistryMu.Unlock()

Expand Down

0 comments on commit fc66f6b

Please sign in to comment.