Files
conduit/provider/provider.go
2025-10-10 10:05:28 +02:00

30 lines
579 B
Go

package provider
import (
"fmt"
"github.com/hashicorp/hcl/v2"
)
type Config struct {
// Name is a unique identifier for the provider.
Name string
// Init is called once to initialize the provider from the matching configuration block.
Init func(hcl.Body) error
}
var providerConfigs = make(map[string]*Config)
func Init(name string, body hcl.Body) error {
p, ok := providerConfigs[name]
if ok {
return p.Init(body)
}
return fmt.Errorf("provider: no %q provider available", name)
}
func Register(provider *Config) {
providerConfigs[provider.Name] = provider
}