Documentation ¶
Overview ¶
Package tfschema contains routines for retrieving the schema info from Terraform and it's providers. This primarily works by interacting with the terraform binary and using the `providers schema` command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSchemas ¶
func GetSchemas( logger *zap.SugaredLogger, ctx context.Context, tfVersion *version.Version, req SchemaRequestList, ) (out *tfjson.ProviderSchemas, returnErr error)
GetSchemas returns the resource and data source schemas for the requested providers using the Terraform binary and the `providers get` command.
This function will look for a Terraform binary that matches the given requested version on the local machine. If it cannot find one in the machine PATH, then this will install a new one in a temporary directory that is removed later.
The providers are pulled down using `terraform init` against a basic Terraform module that only lists all the requested providers as required_providers. We use Jsonnet to render this basic Terraform module given the schema request. The module is rendered into a temporary directory that is cleaned up at the end of the function.
Types ¶
type SchemaRequest ¶
type SchemaRequest struct { // name represents the provider name. Name string `json:"name"` // src represents the provider src for retrieving the schema. For example, hashicorp/aws or DopplerHQ/doppler. Src string `json:"src"` // version represents a version constraint to use for retrieving the specific provider version to use when retrieving // the schema information. Version string `json:"version"` }
SchemaRequest represents a request to retrieve schemas for a single Terraform provider.
func NewSchemaRequest ¶
func NewSchemaRequest(provider, version string) (*SchemaRequest, error)
NewSchemaRequest constructs a new schema request given a canonical provider source string (e.g., aws or DopplerHQ/doppler) and version constraint.
type SchemaRequestList ¶
type SchemaRequestList []*SchemaRequest
SchemaRequestList represets a request to retrieve schemas for multiple Terraform providers.