tf

package
v0.7.0-9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tf parses Terraform provider schemas (from "terraform providers schema -json") and converts them to gogen.ResourceSchema values for Go code generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Fetcher Fetcher
	// contains filtered or unexported fields
}

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

func NewAdapter(fetcher Fetcher, provider, version string) *Adapter

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

func (a *Adapter) FetchConfiguration(ctx context.Context) (*gogen.ConfigurationSchema, error)

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

func (a *Adapter) Name() string

type CLIFetcher

type CLIFetcher struct{}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL