Documentation ¶
Overview ¶
Package terragen provides a simple way to generate Go code from a terraform provider.
Index ¶
- Variables
- func GenerateGoCode(args GenerateGoArgs, providerSchema *tfjson.ProviderSchema) error
- func GenerateProviderSchema(ctx context.Context, provider Provider, opts ...GenerateOption) (*tfjson.ProviderSchema, error)
- type GenerateGoArgs
- type GenerateOption
- type Provider
- type RequiredProviders
- type TerraformBlock
- type TerraformVersions
Constants ¶
This section is empty.
Variables ¶
var ( ErrPackageLocationNotEmpty = errors.New( "providers pkg location is not empty", ) ErrProviderSchemaNotFound = errors.New("provider schema not found") )
Functions ¶
func GenerateGoCode ¶
func GenerateGoCode( args GenerateGoArgs, providerSchema *tfjson.ProviderSchema, ) error
GenerateGoCode generates Go code for creating Terraform objects for the given providers and their schemas.
func GenerateProviderSchema ¶
func GenerateProviderSchema( ctx context.Context, provider Provider, opts ...GenerateOption, ) (*tfjson.ProviderSchema, error)
GenerateProviderSchema generates the schema for the given Terraform provider.
The provider schema is generated by calling Terraform as follows:
terraform providers schema --json
The JSON schema is then decoded and returned as a ProviderSchemas struct.
Types ¶
type GenerateGoArgs ¶
type GenerateGoArgs struct { ProviderName string ProviderSource string ProviderVersion string // OutDir is the filesystem location where the generated files will be // created. OutDir string // Force enables overriding any existing generated files per-provider. Force bool // Clean enables cleaning the generated files location before generating the // new files. Clean bool }
type GenerateOption ¶
type GenerateOption func(*generateOpts)
func WithGenerateCmd ¶
func WithGenerateCmd(cmd string) GenerateOption
type Provider ¶
type Provider struct { Name string // Lack of cty tag means it is ignored Source string `cty:"source"` Version string `cty:"version"` }
Provider represents a single element of a map of required providers
func ParseProvider ¶
ParseProvider takes a provider as a string and returns a Provider object. An error is returned if the string could not be parsed. Example provider: aws=hashicorp/aws:4.60.0
type RequiredProviders ¶
RequiredProviders represents the map of required providers for a Terraform stack
type TerraformBlock ¶
type TerraformBlock struct {
RequiredProviders RequiredProviders `hcl:"required_providers,block"`
}
TerraformBlock represents a terraform{} block in a Terraform stack
type TerraformVersions ¶
type TerraformVersions struct {
TerraformBlock TerraformBlock `hcl:"terraform,block"`
}
TerraformVersions ...