tfconf

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tfconf is the representation of a Terraform Module

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" xml:"name" yaml:"name"`
	Type        types.String `json:"type" xml:"type" yaml:"type"`
	Description types.String `json:"description" xml:"description" yaml:"description"`
	Default     types.Value  `json:"default" xml:"default" yaml:"default"`
	Required    bool         `json:"required" xml:"required" yaml:"required"`
	Position    Position     `json:"-" xml:"-" yaml:"-"`
}

Input represents a Terraform input.

func (*Input) GetValue

func (i *Input) GetValue() string

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

func (i *Input) HasDefault() bool

HasDefault indicates if a Terraform variable has a default value set.

type Module

type Module struct {
	XMLName xml.Name `json:"-" xml:"module" yaml:"-"`

	Header       string         `json:"header" xml:"header" yaml:"header"`
	Inputs       []*Input       `json:"inputs" xml:"inputs>input" yaml:"inputs"`
	Outputs      []*Output      `json:"outputs" xml:"outputs>output" yaml:"outputs"`
	Providers    []*Provider    `json:"providers" xml:"providers>provider" yaml:"providers"`
	Requirements []*Requirement `json:"requirements" xml:"requirements>requirement" yaml:"requirements"`

	RequiredInputs []*Input `json:"-" xml:"-" yaml:"-"`
	OptionalInputs []*Input `json:"-" xml:"-" yaml:"-"`
}

Module represents a Terraform module. It consists of

- Header ('header' json key): Module header found in shape of multi line comments at the beginning of 'main.tf' - Inputs ('inputs' json key): List of input 'variables' extracted from the Terraform module .tf files - Outputs ('outputs' json key): List of 'outputs' extracted from Terraform module .tf files - Providers ('providers' json key): List of 'providers' extracted from resources used in Terraform module - Requirements ('header' json key): List of 'requirements' extracted from the Terraform module .tf files

func (*Module) HasHeader

func (m *Module) HasHeader() bool

HasHeader indicates if the module has header.

func (*Module) HasInputs

func (m *Module) HasInputs() bool

HasInputs indicates if the module has inputs.

func (*Module) HasOutputs

func (m *Module) HasOutputs() bool

HasOutputs indicates if the module has outputs.

func (*Module) HasProviders

func (m *Module) HasProviders() bool

HasProviders indicates if the module has providers.

func (*Module) HasRequirements

func (m *Module) HasRequirements() bool

HasRequirements indicates if the module has requirements.

type Output

type Output struct {
	Name        string       `json:"name" xml:"name" yaml:"name"`
	Description types.String `json:"description" xml:"description" yaml:"description"`
	Value       types.Value  `json:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"`
	Sensitive   bool         `json:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"`
	Position    Position     `json:"-" xml:"-" yaml:"-"`
	ShowValue   bool         `json:"-" xml:"-" yaml:"-"`
}

Output represents a Terraform output.

func (*Output) GetValue

func (o *Output) GetValue() string

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

func (o *Output) HasDefault() bool

HasDefault indicates if a Terraform output has a default value set.

func (*Output) MarshalJSON

func (o *Output) MarshalJSON() ([]byte, error)

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

func (o *Output) MarshalXML(e *xml.Encoder, start xml.StartElement) error

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

func (o *Output) MarshalYAML() (interface{}, error)

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:"-" xml:"-" yaml:"-"`
	Line     int    `json:"-" xml:"-" yaml:"-"`
}

Position represents position of Terraform input or output in a file.

type Provider

type Provider struct {
	Name     string       `json:"name" xml:"name" yaml:"name"`
	Alias    types.String `json:"alias" xml:"alias" yaml:"alias"`
	Version  types.String `json:"version" xml:"version" yaml:"version"`
	Position Position     `json:"-" xml:"-" yaml:"-"`
}

Provider represents a Terraform output.

func (*Provider) FullName

func (p *Provider) FullName() string

FullName returns full name of the provider, with alias if available

type Requirement

type Requirement struct {
	Name    string       `json:"name" xml:"name" yaml:"name"`
	Version types.String `json:"version" xml:"version" yaml:"version"`
}

Requirement represents a requirement for Terraform module.

Jump to

Keyboard shortcuts

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