Documentation ¶
Overview ¶
Package terraform is the representation of a Terraform Module.
It contains:
• Header: Module header found in shape of multi line '*.tf' comments or an entire file
• Footer: Module footer found in shape of multi line '*.tf' comments or an entire file
• Inputs: List of input 'variables' extracted from the Terraform module .tf files
• ModuleCalls: List of 'modules' extracted from the Terraform module .tf files
• Outputs: List of 'outputs' extracted from Terraform module .tf files
• Providers: List of 'providers' extracted from resources used in Terraform module
• Requirements: List of 'requirements' extracted from the Terraform module .tf files
• Resources: List of 'resources' extracted from the Terraform module .tf files
Usage
options := &terraform.Options{ Path: "./examples", ShowHeader: true, HeaderFromFile: "main.tf", ShowFooter: true, FooterFromFile: "footer.md", SortBy: &terraform.SortBy{ Name: true, }, ReadComments: true, } tfmodule, err := terraform.LoadWithOptions(options) if err != nil { log.Fatal(err) } ...
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct { Name string `json:"name" toml:"name" xml:"name" yaml:"name"` Type types.String `json:"type" toml:"type" xml:"type" yaml:"type"` Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"` Default types.Value `json:"default" toml:"default" xml:"default" yaml:"default"` Required bool `json:"required" toml:"required" xml:"required" yaml:"required"` Position Position `json:"-" toml:"-" xml:"-" yaml:"-"` }
Input represents a Terraform input.
func (*Input) GetValue ¶
GetValue returns JSON representation of the 'Default' value, which is an 'interface'. If 'Default' is a primitive type, the primitive value of 'Default' will be returned and not the JSON formatted of it.
func (*Input) HasDefault ¶
HasDefault indicates if a Terraform variable has a default value set.
type Module ¶
type Module struct { XMLName xml.Name `json:"-" toml:"-" xml:"module" yaml:"-"` Header string `json:"header" toml:"header" xml:"header" yaml:"header"` Inputs []*Input `json:"inputs" toml:"inputs" xml:"inputs>input" yaml:"inputs"` ModuleCalls []*ModuleCall `json:"modules" toml:"modules" xml:"modules>module" yaml:"modules"` Outputs []*Output `json:"outputs" toml:"outputs" xml:"outputs>output" yaml:"outputs"` Providers []*Provider `json:"providers" toml:"providers" xml:"providers>provider" yaml:"providers"` Requirements []*Requirement `json:"requirements" toml:"requirements" xml:"requirements>requirement" yaml:"requirements"` Resources []*Resource `json:"resources" toml:"resources" xml:"resources>resource" yaml:"resources"` RequiredInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"` OptionalInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"` }
Module represents a Terraform module. It consists of
func LoadWithOptions ¶
LoadWithOptions returns new instance of Module with all the inputs and outputs discovered from provided 'path' containing Terraform config
func (*Module) HasModuleCalls ¶
HasModuleCalls indicates if the module has modulecalls.
func (*Module) HasOutputs ¶
HasOutputs indicates if the module has outputs.
func (*Module) HasProviders ¶
HasProviders indicates if the module has providers.
func (*Module) HasRequirements ¶
HasRequirements indicates if the module has requirements.
func (*Module) HasResources ¶
HasResources indicates if the module has resources.
type ModuleCall ¶
type ModuleCall struct { Name string `json:"name" toml:"name" xml:"name" yaml:"name"` Source string `json:"source" toml:"source" xml:"source" yaml:"source"` Version string `json:"version" toml:"version" xml:"version" yaml:"version"` Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"` Position Position `json:"-" toml:"-" xml:"-" yaml:"-"` }
ModuleCall represents a submodule called by Terraform module.
func (*ModuleCall) FullName ¶
func (mc *ModuleCall) FullName() string
FullName returns full name of the modulecall, with version if available
type Output ¶
type Output struct { Name string `json:"name" toml:"name" xml:"name" yaml:"name"` Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"` Value types.Value `json:"value,omitempty" toml:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"` Sensitive bool `json:"sensitive,omitempty" toml:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"` Position Position `json:"-" toml:"-" xml:"-" yaml:"-"` ShowValue bool `json:"-" toml:"-" xml:"-" yaml:"-"` }
Output represents a Terraform output.
func (*Output) GetValue ¶
GetValue returns JSON representation of the 'Value', which is an 'interface'. If 'Value' is a primitive type, the primitive value of 'Value' will be returned and not the JSON formatted of it.
func (*Output) HasDefault ¶
HasDefault indicates if a Terraform output has a default value set.
func (*Output) MarshalJSON ¶
MarshalJSON custom yaml marshal function to take '--output-values' flag into consideration. It means if the flag is not set Value and Sensitive fields are set to 'omitempty', otherwise if output values are being shown 'omitempty' gets explicitly removed to show even empty and false values.
func (*Output) MarshalXML ¶
MarshalXML custom xml marshal function to take '--output-values' flag into consideration. It means if the flag is not set Value and Sensitive fields are set to 'omitempty', otherwise if output values are being shown 'omitempty' gets explicitly removed to show even empty and false values.
func (*Output) MarshalYAML ¶
MarshalYAML custom yaml marshal function to take '--output-values' flag into consideration. It means if the flag is not set Value and Sensitive fields are set to 'omitempty', otherwise if output values are being shown 'omitempty' gets explicitly removed to show even empty and false values.
type Position ¶
type Position struct { Filename string `json:"-" toml:"-" xml:"-" yaml:"-"` Line int `json:"-" toml:"-" xml:"-" yaml:"-"` }
Position represents position of Terraform item (input, output, provider, etc) in a file.
type Provider ¶
type Provider struct { Name string `json:"name" toml:"name" xml:"name" yaml:"name"` Alias types.String `json:"alias" toml:"alias" xml:"alias" yaml:"alias"` Version types.String `json:"version" toml:"version" xml:"version" yaml:"version"` Position Position `json:"-" toml:"-" xml:"-" yaml:"-"` }
Provider represents a Terraform output.
type Requirement ¶
type Requirement struct { Name string `json:"name" toml:"name" xml:"name" yaml:"name"` Version types.String `json:"version" toml:"version" xml:"version" yaml:"version"` }
Requirement represents a requirement for Terraform module.
type Resource ¶
type Resource struct { Type string `json:"type" toml:"type" xml:"type" yaml:"type"` Name string `json:"name" toml:"name" xml:"name" yaml:"name"` ProviderName string `json:"provider" toml:"provider" xml:"provider" yaml:"provider"` ProviderSource string `json:"source" toml:"source" xml:"source" yaml:"source"` Mode string `json:"mode" toml:"mode" xml:"mode" yaml:"mode"` Version types.String `json:"version" toml:"version" xml:"version" yaml:"version"` Description types.String `json:"description" toml:"description" xml:"description" yaml:"description"` Position Position `json:"-" toml:"-" xml:"-" yaml:"-"` }
Resource represents a managed or data type that is created by the module
func (*Resource) Spec ¶
Spec returns the resource spec addresses a specific resource in the config. It takes the form: resource_type.resource_name[resource index] For more details, see: https://www.terraform.io/docs/cli/state/resource-addressing.html#resource-spec