Documentation ¶
Index ¶
- Variables
- func ExecTemplate(buildData *BuildData, name string, text string) (*bytes.Buffer, error)
- func TemplateWrite(buildData *BuildData, name string, text string, target string) error
- func TraverseUpDirectory(path string, visit func(dir string) (bool, error)) error
- type BuildData
- type Config
- type ExecBlock
- type ExecPlanBlock
- type RequiredProvider
- type TerraConfig
- type TerraLocals
- type TerraRequiredProviders
- type TerraTemplate
- type TerraValues
- type TerraVariables
- type Terrafile
- func (t *Terrafile) BuildData() (*BuildData, error)
- func (t *Terrafile) Locals() map[string]cty.Value
- func (t *Terrafile) LocalsAsGo() (map[string]interface{}, error)
- func (t *Terrafile) RelativeDir() string
- func (t *Terrafile) RelativePath() string
- func (t *Terrafile) RelativeRootDir() string
- func (t *Terrafile) RootDir() string
- func (t *Terrafile) Values() map[string]cty.Value
- func (t *Terrafile) ValuesAsGo() (map[string]interface{}, error)
- func (t *Terrafile) Variables() map[string]cty.Value
- func (t *Terrafile) VariablesAsGo() (map[string]interface{}, error)
- type TerraformBlock
Constants ¶
This section is empty.
Variables ¶
var DefaultTerrafile = Terrafile{ ExecBlock: &ExecBlock{ PlanBlock: &ExecPlanBlock{ Input: false, Lock: true, Out: "tfplan", SkipOut: false, }, }, TerraformBlock: &TerraformBlock{ RequiredProvidersBlock: &TerraRequiredProviders{ RequiredProviders: make(map[string]RequiredProvider), }, }, }
DefaultTerrafile sets default values for a Terrafile that are used when parsing a new Terrafile
Functions ¶
func ExecTemplate ¶
func TemplateWrite ¶
func TraverseUpDirectory ¶
TraverseUpDirectory takes a path and a callback function. For each directory that is an ancestor of path (and including path), call the callback function. Callback returns an error if something went wrong (which stops the traversal) and a boolean: if true is returned the traversal continues, if false the traversal finishes gracefully
Types ¶
type BuildData ¶
type BuildData struct { Locals map[string]interface{} Variables map[string]interface{} Values map[string]interface{} Terrafile *Terrafile // RelativeDir is the relative directory from the root Terrafile to the // Terrafile being built RelativeDir string // RelativePath is the relative path from the root Terrafile to the Terrafile // being built RelativePath string // RelativeRootDir is the relative directory of the root Terrafile RelativeRootDir string // RootDir is the absolute directory of the root Terrafile RootDir string }
BuildData defines the data which is passed to the Go template engine
type ExecBlock ¶
type ExecBlock struct { Skip bool `hcl:"skip,optional"` ExtraArgs []string `hcl:"extra_args,optional"` PlanBlock *ExecPlanBlock `hcl:"plan,block"` }
type ExecPlanBlock ¶
type ExecPlanBlock struct { Input bool `hcl:"input,optional"` Lock bool `hcl:"lock,optional"` // Out specifies the name of the Terraform plan file to create (if any) Out string `hcl:"out,optional"` // SkipOut says whether to avoid creating a plan file or not. Useful in cases // such as running Terraform Cloud remotely, where plans cannot be created. SkipOut bool `hcl:"skip_out,optional"` }
ExecPlanBlock defines the arguments for running the Terraform plan
type RequiredProvider ¶
type RequiredProvider struct { Source string `hcl:"source,attr" cty:"source"` Version string `hcl:"version,attr" cty:"version"` }
RequiredProvider defines the body of required_providers
type TerraConfig ¶
func Parse ¶
func Parse(config *Config) (*TerraConfig, error)
func (*TerraConfig) MergeTerrafiles ¶
func (c *TerraConfig) MergeTerrafiles() error
func (*TerraConfig) RootModules ¶
func (c *TerraConfig) RootModules() []*Terrafile
RootModules returns the Terrafiles that are considered root modules and should therefore be processed
func (*TerraConfig) RootTerrafiles ¶
func (c *TerraConfig) RootTerrafiles() []*Terrafile
RootTerrafile returns the top-most (root) Terrafiles. It's possible that there's multiple root terrafiles if there are multiple trees of terrafiles that have been parsed
type TerraLocals ¶
type TerraRequiredProviders ¶
type TerraRequiredProviders struct {
RequiredProviders map[string]RequiredProvider `hcl:",remain"`
}
TerraRequiredProviders defines the map of required_providers
type TerraTemplate ¶
type TerraTemplate struct { Name string `hcl:",label"` Contents string `hcl:"contents,attr"` // Target defines the target file to generate. // Defaults to the Name of the template with a ".tp.tf" extension Target string `hcl:"target,optional"` // ConditionAttr defines a string boolean that specifies whether this template // should be built or not. // The string can include Go templates, which means you can have dynamic // behaviour based on the Terrafile ConditionAttr string `hcl:"condition,optional"` }
TerraTemplate defines the template{} block within a Terrafile
type TerraValues ¶
type TerraVariables ¶
type Terrafile ¶
type Terrafile struct { // Path Path string Dir string // IsRoot tells whether this terrafile is for a root module IsRoot bool // Templates defines the list of templates that this Terrafile defines Templates []*TerraTemplate `hcl:"template,block"` LocalsBlock *TerraLocals `hcl:"locals,block"` VariablesBlock *TerraVariables `hcl:"variables,block"` ValuesBlock *TerraValues `hcl:"values,block"` TerraformBlock *TerraformBlock `hcl:"terraform,block"` // BuildBlock *BuildBlock `hcl:"build,block"` ExecBlock *ExecBlock `hcl:"exec,block"` // Ancestor defines any parent/ancestor Terrafiles that this Terrafile // should inherit from Ancestor *Terrafile // Children contains any child Terrafiles to this Terrafile Children []*Terrafile }
func (*Terrafile) LocalsAsGo ¶
func (*Terrafile) RelativeDir ¶
RelativeDir gets the relative directory from the Root Terrafile to this Terrafile
func (*Terrafile) RelativePath ¶
RelativePath gets the relative directory from the Root Terrafile to this Terrafile
func (*Terrafile) RelativeRootDir ¶
RelativeRootDir returns the relative directory of the root Terrafile
func (*Terrafile) ValuesAsGo ¶
func (*Terrafile) VariablesAsGo ¶
type TerraformBlock ¶
type TerraformBlock struct { RequiredVersion string `hcl:"required_version,optional"` RequiredProvidersBlock *TerraRequiredProviders `hcl:"required_providers,block"` }
TerraformBlock defines the terraform{} block within a Terrafile
func (*TerraformBlock) RequiredProviders ¶
func (tb *TerraformBlock) RequiredProviders() map[string]RequiredProvider
RequiredProviders returns the map of terraform required_providers, or nil