package tf¶
Package tf parses Terraform provider schemas (from "terraform providers schema -json") and converts them to gogen.ResourceSchema values for Go code generation.
Types¶
type Adapter¶
Adapter implements gogen.SchemaAdapter backed by TF provider schemas. provider is the fully-qualified TF registry source (e.g. "hashicorp/aws" or "ansible/ansible"). The part after the final slash becomes the local provider name for the terraform block and the Go package name.
func NewAdapter¶
NewAdapter creates an Adapter for the given fully-qualified provider source. version is an optional TF version constraint (e.g. "~> 5.0").
func (*Adapter) FetchConfiguration¶
FetchConfiguration extracts the TF provider's own configuration block (e.g. aws { region = ... }) and returns it as a generic schema for the renderer. A nil result means the provider declares no configuration attributes; the renderer then skips emitting a ProviderConfig struct and library Configuration entry.
func (*Adapter) FetchDataSources¶
func (a *Adapter) FetchDataSources(
ctx context.Context,
resources []string,
) ([]gogen.DataSourceSchema, error)
func (*Adapter) FetchResources¶
func (a *Adapter) FetchResources(
ctx context.Context,
resources []string,
) ([]gogen.ResourceSchema, error)
func (*Adapter) Name¶
type CLIFetcher¶
CLIFetcher runs terraform in a temp directory.
func (CLIFetcher) FetchSchema¶
func (CLIFetcher) FetchSchema(
ctx context.Context,
source, localName, version string,
) ([]byte, error)
type Fetcher¶
type Fetcher interface {
FetchSchema(ctx context.Context, source, localName, version string) ([]byte, error)
}
Fetcher abstracts terraform CLI calls for testability.