Documentation ¶
Index ¶
- func SplitTokensAsList(tokens hclwrite.Tokens) []hclwrite.Tokens
- type Attribute
- type Block
- type DataSource
- func (b DataSource) AppendAttribute(attr *Attribute)
- func (b DataSource) AppendNestedBlock(nestedBlock Block)
- func (b DataSource) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b DataSource) Attributes() []*Attribute
- func (b DataSource) CopyAttribute(from Block, name string)
- func (r *DataSource) Count() *Attribute
- func (b DataSource) FindNestedBlocksByType(blockType string) []Block
- func (r *DataSource) ForEach() *Attribute
- func (b DataSource) GetAttribute(name string) *Attribute
- func (r *DataSource) Name() string
- func (b DataSource) NestedBlocks() []*NestedBlock
- func (b DataSource) Raw() *hclwrite.Block
- func (r *DataSource) ReferableName() string
- func (b DataSource) References() []string
- func (b DataSource) RemoveAttribute(name string)
- func (b DataSource) RemoveNestedBlock(nestedBlock Block)
- func (b DataSource) RenameReference(from string, to string)
- func (b DataSource) SchemaType() string
- func (b DataSource) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b DataSource) SetAttributeValue(name string, value cty.Value)
- func (b DataSource) SetType(typeName string)
- func (b DataSource) Type() string
- func (b DataSource) VerticalFormat()
- type File
- type Locals
- func (b Locals) AppendAttribute(attr *Attribute)
- func (b Locals) AppendNestedBlock(nestedBlock Block)
- func (b Locals) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Locals) Attributes() []*Attribute
- func (b Locals) CopyAttribute(from Block, name string)
- func (b Locals) FindNestedBlocksByType(blockType string) []Block
- func (b Locals) GetAttribute(name string) *Attribute
- func (b Locals) NestedBlocks() []*NestedBlock
- func (b Locals) Raw() *hclwrite.Block
- func (b Locals) References() []string
- func (b Locals) RemoveAttribute(name string)
- func (b Locals) RemoveNestedBlock(nestedBlock Block)
- func (b Locals) RenameReference(from string, to string)
- func (b Locals) SchemaType() string
- func (b Locals) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Locals) SetAttributeValue(name string, value cty.Value)
- func (b Locals) SetType(typeName string)
- func (b Locals) Type() string
- func (b Locals) VerticalFormat()
- type Module
- func (b Module) AppendAttribute(attr *Attribute)
- func (b Module) AppendNestedBlock(nestedBlock Block)
- func (b Module) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Module) Attributes() []*Attribute
- func (b Module) CopyAttribute(from Block, name string)
- func (b Module) FindNestedBlocksByType(blockType string) []Block
- func (b Module) GetAttribute(name string) *Attribute
- func (b Module) NestedBlocks() []*NestedBlock
- func (b Module) Raw() *hclwrite.Block
- func (b Module) References() []string
- func (b Module) RemoveAttribute(name string)
- func (b Module) RemoveNestedBlock(nestedBlock Block)
- func (b Module) RenameReference(from string, to string)
- func (b Module) SchemaType() string
- func (b Module) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Module) SetAttributeValue(name string, value cty.Value)
- func (b Module) SetType(typeName string)
- func (b Module) Type() string
- func (b Module) VerticalFormat()
- type Moved
- func (b Moved) AppendAttribute(attr *Attribute)
- func (b Moved) AppendNestedBlock(nestedBlock Block)
- func (b Moved) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Moved) Attributes() []*Attribute
- func (b Moved) CopyAttribute(from Block, name string)
- func (b Moved) FindNestedBlocksByType(blockType string) []Block
- func (b Moved) GetAttribute(name string) *Attribute
- func (b Moved) NestedBlocks() []*NestedBlock
- func (b Moved) Raw() *hclwrite.Block
- func (b Moved) References() []string
- func (b Moved) RemoveAttribute(name string)
- func (b Moved) RemoveNestedBlock(nestedBlock Block)
- func (b Moved) RenameReference(from string, to string)
- func (b Moved) SchemaType() string
- func (b Moved) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Moved) SetAttributeValue(name string, value cty.Value)
- func (b Moved) SetType(typeName string)
- func (b Moved) Type() string
- func (b Moved) VerticalFormat()
- type NestedBlock
- func (b NestedBlock) AppendAttribute(attr *Attribute)
- func (b NestedBlock) AppendNestedBlock(nestedBlock Block)
- func (b NestedBlock) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b NestedBlock) Attributes() []*Attribute
- func (b NestedBlock) CopyAttribute(from Block, name string)
- func (b NestedBlock) FindNestedBlocksByType(blockType string) []Block
- func (b NestedBlock) GetAttribute(name string) *Attribute
- func (b NestedBlock) NestedBlocks() []*NestedBlock
- func (b NestedBlock) Raw() *hclwrite.Block
- func (b NestedBlock) References() []string
- func (b NestedBlock) RemoveAttribute(name string)
- func (b NestedBlock) RemoveNestedBlock(nestedBlock Block)
- func (b NestedBlock) RenameReference(from string, to string)
- func (b NestedBlock) SchemaType() string
- func (b NestedBlock) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b NestedBlock) SetAttributeValue(name string, value cty.Value)
- func (b NestedBlock) SetType(typeName string)
- func (b NestedBlock) Type() string
- func (b NestedBlock) VerticalFormat()
- type Output
- func (b Output) AppendAttribute(attr *Attribute)
- func (b Output) AppendNestedBlock(nestedBlock Block)
- func (b Output) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Output) Attributes() []*Attribute
- func (b Output) CopyAttribute(from Block, name string)
- func (b Output) FindNestedBlocksByType(blockType string) []Block
- func (b Output) GetAttribute(name string) *Attribute
- func (b Output) NestedBlocks() []*NestedBlock
- func (b Output) Raw() *hclwrite.Block
- func (b Output) References() []string
- func (b Output) RemoveAttribute(name string)
- func (b Output) RemoveNestedBlock(nestedBlock Block)
- func (b Output) RenameReference(from string, to string)
- func (b Output) SchemaType() string
- func (b Output) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Output) SetAttributeValue(name string, value cty.Value)
- func (b Output) SetType(typeName string)
- func (b Output) Type() string
- func (b Output) VerticalFormat()
- type Provider
- func (b Provider) AppendAttribute(attr *Attribute)
- func (b Provider) AppendNestedBlock(nestedBlock Block)
- func (b Provider) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Provider) Attributes() []*Attribute
- func (b Provider) CopyAttribute(from Block, name string)
- func (b Provider) FindNestedBlocksByType(blockType string) []Block
- func (b Provider) GetAttribute(name string) *Attribute
- func (b Provider) NestedBlocks() []*NestedBlock
- func (b Provider) Raw() *hclwrite.Block
- func (b Provider) References() []string
- func (b Provider) RemoveAttribute(name string)
- func (b Provider) RemoveNestedBlock(nestedBlock Block)
- func (b Provider) RenameReference(from string, to string)
- func (b Provider) SchemaType() string
- func (b Provider) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Provider) SetAttributeValue(name string, value cty.Value)
- func (b Provider) SetType(typeName string)
- func (b Provider) Type() string
- func (b Provider) VerticalFormat()
- type Resource
- func (b Resource) AppendAttribute(attr *Attribute)
- func (b Resource) AppendNestedBlock(nestedBlock Block)
- func (b Resource) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Resource) Attributes() []*Attribute
- func (b Resource) CopyAttribute(from Block, name string)
- func (r *Resource) Count() *Attribute
- func (b Resource) FindNestedBlocksByType(blockType string) []Block
- func (r *Resource) ForEach() *Attribute
- func (b Resource) GetAttribute(name string) *Attribute
- func (r *Resource) Name() string
- func (b Resource) NestedBlocks() []*NestedBlock
- func (b Resource) Raw() *hclwrite.Block
- func (r *Resource) ReferableName() string
- func (b Resource) References() []string
- func (b Resource) RemoveAttribute(name string)
- func (b Resource) RemoveNestedBlock(nestedBlock Block)
- func (b Resource) RenameReference(from string, to string)
- func (b Resource) SchemaType() string
- func (r *Resource) SetAttributeByReference(name string, refResource *Resource, refAttribute string)
- func (b Resource) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Resource) SetAttributeValue(name string, value cty.Value)
- func (b Resource) SetType(typeName string)
- func (b Resource) Type() string
- func (b Resource) VerticalFormat()
- type Terraform
- func (b Terraform) AppendAttribute(attr *Attribute)
- func (b Terraform) AppendNestedBlock(nestedBlock Block)
- func (b Terraform) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Terraform) Attributes() []*Attribute
- func (b Terraform) CopyAttribute(from Block, name string)
- func (b Terraform) FindNestedBlocksByType(blockType string) []Block
- func (b Terraform) GetAttribute(name string) *Attribute
- func (b Terraform) NestedBlocks() []*NestedBlock
- func (b Terraform) Raw() *hclwrite.Block
- func (b Terraform) References() []string
- func (b Terraform) RemoveAttribute(name string)
- func (b Terraform) RemoveNestedBlock(nestedBlock Block)
- func (b Terraform) RenameReference(from string, to string)
- func (b Terraform) SchemaType() string
- func (b Terraform) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Terraform) SetAttributeValue(name string, value cty.Value)
- func (b Terraform) SetType(typeName string)
- func (b Terraform) Type() string
- func (b Terraform) VerticalFormat()
- type Variable
- func (b Variable) AppendAttribute(attr *Attribute)
- func (b Variable) AppendNestedBlock(nestedBlock Block)
- func (b Variable) AppendUnwrappedNestedBlockBody(nestedBlock Block)
- func (b Variable) Attributes() []*Attribute
- func (b Variable) CopyAttribute(from Block, name string)
- func (b Variable) FindNestedBlocksByType(blockType string) []Block
- func (b Variable) GetAttribute(name string) *Attribute
- func (b Variable) NestedBlocks() []*NestedBlock
- func (b Variable) Raw() *hclwrite.Block
- func (b Variable) References() []string
- func (b Variable) RemoveAttribute(name string)
- func (b Variable) RemoveNestedBlock(nestedBlock Block)
- func (b Variable) RenameReference(from string, to string)
- func (b Variable) SchemaType() string
- func (b Variable) SetAttributeRaw(name string, tokens hclwrite.Tokens)
- func (b Variable) SetAttributeValue(name string, value cty.Value)
- func (b Variable) SetType(typeName string)
- func (b Variable) Type() string
- func (b Variable) VerticalFormat()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute is an attribute of resource.
func NewAttribute ¶
NewAttribute creates a new instance of Attribute.
func (*Attribute) References ¶ added in v0.2.1
References returns all variable references contained in the value. It returns a unique and sorted list.
func (*Attribute) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references contained in the value. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (*Attribute) ValueAsString ¶
ValueAsString returns a value of Attribute as string.
func (*Attribute) ValueAsTokens ¶
ValueAsTokens returns a value of Attribute as raw tokens.
type Block ¶
type Block interface { // Raw returns a raw block instance of hclwrite. // It should keep it private if possible, but it's required for some // operations. Raw() *hclwrite.Block // Type returns a type of block. Type() string // SchemaType returns the first label of block. // If it does not have a label, return an empty string. // Note that it's not the same as the *hclwrite.Block.Type(). SchemaType() string // SetType updates the type name of the block to a given name. SetType(typeName string) // Attributes returns all attributes. // Note that this does not return attributes in nested blocks. Attributes() []*Attribute // GetAttribute returns an attribute for a given name. GetAttribute(name string) *Attribute // SetAttributeValue sets an attribute for a given name with value. SetAttributeValue(name string, value cty.Value) // SetAttributeRaw sets an attribute for a given name with raw tokens. SetAttributeRaw(name string, tokens hclwrite.Tokens) // AppendAttribute appends a given attribute to the block. AppendAttribute(attr *Attribute) // RemoveAttribute removes an attribute for a given name from the block. RemoveAttribute(name string) // CopyAttribute is a helper method which copies an attribute from a given block. // Do nothing if the given block doesn't have the attribute. CopyAttribute(from Block, name string) // NestedBlocks returns all nested blocks. NestedBlocks() []*NestedBlock // AppendNestedBlock appends a given nested block to the parent block. AppendNestedBlock(nestedBlock Block) // AppendUnwrappedNestedBlockBody appends a body of a given block to // the parent block. It looks a weird operation, but it's often needed for // refactoring like splitting a resource type for sub resource types. AppendUnwrappedNestedBlockBody(nestedBlock Block) // RemoveNestedBlock removes a given nested block from the parent block. RemoveNestedBlock(nestedBlock Block) // FindNestedBlocksByType returns all matching blocks from the body that have // the given block type or returns an empty list if not found. FindNestedBlocksByType(blockType string) []Block // VerticalFormat formats a body of the block in vertical. Since // VerticalFormat clears tokens internally, If you call VerticalFormat each // time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not // work properly, so call VerticalFormat only once for each block. VerticalFormat() // References returns all variable references for all attributes. // It returns a unique and sorted list. References() []string // RenameReference renames all variable references for all attributes. // The `from` and `to` arguments are specified as dot-delimited resource addresses. // The `from` argument can be a partial prefix match, but must match the length // of the `to` argument. RenameReference(from string, to string) }
Block represents an abstract HCL block.
type DataSource ¶ added in v0.2.0
type DataSource struct {
// contains filtered or unexported fields
}
DataSource represents a data block. It implements the Block interface.
func NewDataSource ¶ added in v0.2.0
func NewDataSource(block *hclwrite.Block) *DataSource
NewDataSource creates a new instance of DataSource.
func NewEmptyDataSource ¶ added in v0.2.0
func NewEmptyDataSource(dataSourceType string, dataSourceName string) *DataSource
NewEmptyDataSource creates a new DataSource with an empty body.
func (DataSource) AppendAttribute ¶ added in v0.2.0
func (b DataSource) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (DataSource) AppendNestedBlock ¶ added in v0.2.0
func (b DataSource) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (DataSource) AppendUnwrappedNestedBlockBody ¶ added in v0.2.0
func (b DataSource) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (DataSource) Attributes ¶ added in v0.2.1
func (b DataSource) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (DataSource) CopyAttribute ¶ added in v0.2.0
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (*DataSource) Count ¶ added in v0.2.0
func (r *DataSource) Count() *Attribute
Count returns a meta argument of count. It returns nil if not found.
func (DataSource) FindNestedBlocksByType ¶ added in v0.2.0
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (*DataSource) ForEach ¶ added in v0.2.0
func (r *DataSource) ForEach() *Attribute
ForEach returns a meta argument of for_each. It returns nil if not found.
func (DataSource) GetAttribute ¶ added in v0.2.0
GetAttribute returns an attribute for a given name.
func (*DataSource) Name ¶ added in v0.2.0
func (r *DataSource) Name() string
Name returns a name of data source. It returns the second label of block.
func (DataSource) NestedBlocks ¶ added in v0.2.1
func (b DataSource) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (DataSource) Raw ¶ added in v0.2.0
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (*DataSource) ReferableName ¶ added in v0.2.0
func (r *DataSource) ReferableName() string
ReferableName returns a name of data source instance which can be referenced as a part of address. It contains an index reference if count or for_each is set. If neither count nor for_each is set, it just returns the name.
func (DataSource) References ¶ added in v0.2.1
func (b DataSource) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (DataSource) RemoveAttribute ¶ added in v0.2.0
func (b DataSource) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (DataSource) RemoveNestedBlock ¶ added in v0.2.0
func (b DataSource) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (DataSource) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (DataSource) SchemaType ¶ added in v0.2.0
func (b DataSource) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (DataSource) SetAttributeRaw ¶ added in v0.2.0
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (DataSource) SetAttributeValue ¶ added in v0.2.0
SetAttributeValue sets an attribute for a given name with value.
func (DataSource) SetType ¶ added in v0.2.0
func (b DataSource) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (DataSource) Type ¶ added in v0.2.0
func (b DataSource) Type() string
Type returns a type of block.
func (DataSource) VerticalFormat ¶ added in v0.2.0
func (b DataSource) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a Terraform configuration file
func (*File) AppendBlock ¶ added in v0.2.0
AppendBlock appends a given block to the file.
func (*File) FindBlocksByType ¶ added in v0.2.0
FindBlocksByType returns all matching blocks from the body that have the given blockType and schemaType or returns an empty list if not found. If the given blockType or schemaType are a non-empty string, filter the results.
type Locals ¶ added in v0.2.1
type Locals struct {
// contains filtered or unexported fields
}
Locals represents a locals block. It implements the Block interface.
func NewEmptyLocals ¶ added in v0.2.1
func NewEmptyLocals() *Locals
NewEmptyLocals creates a new Locals with an empty body.
func (Locals) AppendAttribute ¶ added in v0.2.1
func (b Locals) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Locals) AppendNestedBlock ¶ added in v0.2.1
func (b Locals) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Locals) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Locals) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Locals) Attributes ¶ added in v0.2.1
func (b Locals) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Locals) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Locals) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Locals) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Locals) NestedBlocks ¶ added in v0.2.1
func (b Locals) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Locals) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Locals) References ¶ added in v0.2.1
func (b Locals) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Locals) RemoveAttribute ¶ added in v0.2.1
func (b Locals) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Locals) RemoveNestedBlock ¶ added in v0.2.1
func (b Locals) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Locals) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Locals) SchemaType ¶ added in v0.2.1
func (b Locals) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Locals) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Locals) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Locals) SetType ¶ added in v0.2.1
func (b Locals) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Locals) VerticalFormat ¶ added in v0.2.1
func (b Locals) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Module ¶ added in v0.2.1
type Module struct {
// contains filtered or unexported fields
}
Module represents a module block. It implements the Block interface.
func NewEmptyModule ¶ added in v0.2.1
NewEmptyModule creates a new Module with an empty body.
func (Module) AppendAttribute ¶ added in v0.2.1
func (b Module) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Module) AppendNestedBlock ¶ added in v0.2.1
func (b Module) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Module) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Module) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Module) Attributes ¶ added in v0.2.1
func (b Module) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Module) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Module) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Module) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Module) NestedBlocks ¶ added in v0.2.1
func (b Module) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Module) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Module) References ¶ added in v0.2.1
func (b Module) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Module) RemoveAttribute ¶ added in v0.2.1
func (b Module) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Module) RemoveNestedBlock ¶ added in v0.2.1
func (b Module) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Module) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Module) SchemaType ¶ added in v0.2.1
func (b Module) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Module) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Module) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Module) SetType ¶ added in v0.2.1
func (b Module) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Module) VerticalFormat ¶ added in v0.2.1
func (b Module) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Moved ¶ added in v0.2.1
type Moved struct {
// contains filtered or unexported fields
}
Moved represents a moved block. It implements the Block interface.
func NewEmptyMoved ¶ added in v0.2.1
func NewEmptyMoved() *Moved
NewEmptyMoved creates a new Moved with an empty body.
func (Moved) AppendAttribute ¶ added in v0.2.1
func (b Moved) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Moved) AppendNestedBlock ¶ added in v0.2.1
func (b Moved) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Moved) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Moved) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Moved) Attributes ¶ added in v0.2.1
func (b Moved) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Moved) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Moved) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Moved) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Moved) NestedBlocks ¶ added in v0.2.1
func (b Moved) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Moved) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Moved) References ¶ added in v0.2.1
func (b Moved) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Moved) RemoveAttribute ¶ added in v0.2.1
func (b Moved) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Moved) RemoveNestedBlock ¶ added in v0.2.1
func (b Moved) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Moved) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Moved) SchemaType ¶ added in v0.2.1
func (b Moved) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Moved) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Moved) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Moved) SetType ¶ added in v0.2.1
func (b Moved) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Moved) VerticalFormat ¶ added in v0.2.1
func (b Moved) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type NestedBlock ¶
type NestedBlock struct {
// contains filtered or unexported fields
}
NestedBlock represents a nested block. It implements the Block interface.
func NewEmptyNestedBlock ¶
func NewEmptyNestedBlock(blockType string) *NestedBlock
NewEmptyNestedBlock creates a new NestedBlock with an empty body.
func NewNestedBlock ¶
func NewNestedBlock(block *hclwrite.Block) *NestedBlock
NewNestedBlock creates a new instance of NestedBlock.
func (NestedBlock) AppendAttribute ¶
func (b NestedBlock) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (NestedBlock) AppendNestedBlock ¶
func (b NestedBlock) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (NestedBlock) AppendUnwrappedNestedBlockBody ¶
func (b NestedBlock) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (NestedBlock) Attributes ¶ added in v0.2.1
func (b NestedBlock) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (NestedBlock) CopyAttribute ¶ added in v0.0.3
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (NestedBlock) FindNestedBlocksByType ¶
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (NestedBlock) GetAttribute ¶
GetAttribute returns an attribute for a given name.
func (NestedBlock) NestedBlocks ¶ added in v0.2.1
func (b NestedBlock) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (NestedBlock) Raw ¶
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (NestedBlock) References ¶ added in v0.2.1
func (b NestedBlock) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (NestedBlock) RemoveAttribute ¶
func (b NestedBlock) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (NestedBlock) RemoveNestedBlock ¶
func (b NestedBlock) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (NestedBlock) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (NestedBlock) SchemaType ¶ added in v0.2.0
func (b NestedBlock) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (NestedBlock) SetAttributeRaw ¶
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (NestedBlock) SetAttributeValue ¶
SetAttributeValue sets an attribute for a given name with value.
func (NestedBlock) SetType ¶
func (b NestedBlock) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (NestedBlock) VerticalFormat ¶
func (b NestedBlock) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Output ¶ added in v0.2.1
type Output struct {
// contains filtered or unexported fields
}
Output represents a output block. It implements the Block interface.
func NewEmptyOutput ¶ added in v0.2.1
NewEmptyOutput creates a new Output with an empty body.
func (Output) AppendAttribute ¶ added in v0.2.1
func (b Output) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Output) AppendNestedBlock ¶ added in v0.2.1
func (b Output) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Output) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Output) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Output) Attributes ¶ added in v0.2.1
func (b Output) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Output) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Output) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Output) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Output) NestedBlocks ¶ added in v0.2.1
func (b Output) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Output) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Output) References ¶ added in v0.2.1
func (b Output) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Output) RemoveAttribute ¶ added in v0.2.1
func (b Output) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Output) RemoveNestedBlock ¶ added in v0.2.1
func (b Output) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Output) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Output) SchemaType ¶ added in v0.2.1
func (b Output) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Output) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Output) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Output) SetType ¶ added in v0.2.1
func (b Output) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Output) VerticalFormat ¶ added in v0.2.1
func (b Output) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Provider ¶ added in v0.2.0
type Provider struct {
// contains filtered or unexported fields
}
Provider represents a provider block. It implements the Block interface.
func NewEmptyProvider ¶ added in v0.2.0
NewEmptyProvider creates a new Provider with an empty body.
func NewProvider ¶ added in v0.2.0
NewProvider creates a new instance of Provider.
func (Provider) AppendAttribute ¶ added in v0.2.0
func (b Provider) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Provider) AppendNestedBlock ¶ added in v0.2.0
func (b Provider) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Provider) AppendUnwrappedNestedBlockBody ¶ added in v0.2.0
func (b Provider) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Provider) Attributes ¶ added in v0.2.1
func (b Provider) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Provider) CopyAttribute ¶ added in v0.2.0
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Provider) FindNestedBlocksByType ¶ added in v0.2.0
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Provider) GetAttribute ¶ added in v0.2.0
GetAttribute returns an attribute for a given name.
func (Provider) NestedBlocks ¶ added in v0.2.1
func (b Provider) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Provider) Raw ¶ added in v0.2.0
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Provider) References ¶ added in v0.2.1
func (b Provider) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Provider) RemoveAttribute ¶ added in v0.2.0
func (b Provider) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Provider) RemoveNestedBlock ¶ added in v0.2.0
func (b Provider) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Provider) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Provider) SchemaType ¶ added in v0.2.0
func (b Provider) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Provider) SetAttributeRaw ¶ added in v0.2.0
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Provider) SetAttributeValue ¶ added in v0.2.0
SetAttributeValue sets an attribute for a given name with value.
func (Provider) SetType ¶ added in v0.2.0
func (b Provider) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Provider) Type ¶ added in v0.2.0
func (b Provider) Type() string
Type returns a type of block.
func (Provider) VerticalFormat ¶ added in v0.2.0
func (b Provider) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource represents a resource block. It implements the Block interface.
func NewEmptyResource ¶
NewEmptyResource creates a new Resource with an empty body.
func NewResource ¶
NewResource creates a new instance of Resource.
func (Resource) AppendAttribute ¶
func (b Resource) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Resource) AppendNestedBlock ¶
func (b Resource) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Resource) AppendUnwrappedNestedBlockBody ¶
func (b Resource) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Resource) Attributes ¶ added in v0.2.1
func (b Resource) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Resource) CopyAttribute ¶ added in v0.0.3
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (*Resource) Count ¶ added in v0.0.3
Count returns a meta argument of count. It returns nil if not found.
func (Resource) FindNestedBlocksByType ¶
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (*Resource) ForEach ¶ added in v0.0.3
ForEach returns a meta argument of for_each. It returns nil if not found.
func (Resource) GetAttribute ¶
GetAttribute returns an attribute for a given name.
func (Resource) NestedBlocks ¶ added in v0.2.1
func (b Resource) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Resource) Raw ¶
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (*Resource) ReferableName ¶ added in v0.0.3
ReferableName returns a name of resource instance which can be referenced as a part of address. It contains an index reference if count or for_each is set. If neither count nor for_each is set, it just returns the name.
func (Resource) References ¶ added in v0.2.1
func (b Resource) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Resource) RemoveAttribute ¶
func (b Resource) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Resource) RemoveNestedBlock ¶
func (b Resource) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Resource) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Resource) SchemaType ¶
func (b Resource) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (*Resource) SetAttributeByReference ¶
SetAttributeByReference sets an attribute for a given name to a reference of another resource.
func (Resource) SetAttributeRaw ¶
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Resource) SetAttributeValue ¶
SetAttributeValue sets an attribute for a given name with value.
func (Resource) SetType ¶
func (b Resource) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Resource) VerticalFormat ¶
func (b Resource) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Terraform ¶ added in v0.2.1
type Terraform struct {
// contains filtered or unexported fields
}
Terraform represents a terraform block. It implements the Block interface.
func NewEmptyTerraform ¶ added in v0.2.1
func NewEmptyTerraform() *Terraform
NewEmptyTerraform creates a new Terraform with an empty body.
func NewTerraform ¶ added in v0.2.1
NewTerraform creates a new instance of Terraform.
func (Terraform) AppendAttribute ¶ added in v0.2.1
func (b Terraform) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Terraform) AppendNestedBlock ¶ added in v0.2.1
func (b Terraform) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Terraform) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Terraform) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Terraform) Attributes ¶ added in v0.2.1
func (b Terraform) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Terraform) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Terraform) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Terraform) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Terraform) NestedBlocks ¶ added in v0.2.1
func (b Terraform) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Terraform) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Terraform) References ¶ added in v0.2.1
func (b Terraform) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Terraform) RemoveAttribute ¶ added in v0.2.1
func (b Terraform) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Terraform) RemoveNestedBlock ¶ added in v0.2.1
func (b Terraform) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Terraform) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Terraform) SchemaType ¶ added in v0.2.1
func (b Terraform) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Terraform) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Terraform) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Terraform) SetType ¶ added in v0.2.1
func (b Terraform) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Terraform) Type ¶ added in v0.2.1
func (b Terraform) Type() string
Type returns a type of block.
func (Terraform) VerticalFormat ¶ added in v0.2.1
func (b Terraform) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.
type Variable ¶ added in v0.2.1
type Variable struct {
// contains filtered or unexported fields
}
Variable represents a variable block. It implements the Block interface.
func NewEmptyVariable ¶ added in v0.2.1
NewEmptyVariable creates a new Variable with an empty body.
func NewVariable ¶ added in v0.2.1
NewVariable creates a new instance of Variable.
func (Variable) AppendAttribute ¶ added in v0.2.1
func (b Variable) AppendAttribute(attr *Attribute)
AppendAttribute appends a given attribute to the block.
func (Variable) AppendNestedBlock ¶ added in v0.2.1
func (b Variable) AppendNestedBlock(nestedBlock Block)
AppendNestedBlock appends a given nested block to the parent block.
func (Variable) AppendUnwrappedNestedBlockBody ¶ added in v0.2.1
func (b Variable) AppendUnwrappedNestedBlockBody(nestedBlock Block)
AppendUnwrappedNestedBlockBody appends a body of a given block to the parent block. It looks a weird operation, but it's often needed for refactoring like splitting a resource type for sub resource types.
func (Variable) Attributes ¶ added in v0.2.1
func (b Variable) Attributes() []*Attribute
Attributes returns all attributes. Note that this does not return attributes in nested blocks.
func (Variable) CopyAttribute ¶ added in v0.2.1
CopyAttribute is a helper method which copies an attribute from a given block. Do nothing if the given block doesn't have the attribute.
func (Variable) FindNestedBlocksByType ¶ added in v0.2.1
FindNestedBlocksByType returns all matching blocks from the body that have the given block type or returns an empty list if not found.
func (Variable) GetAttribute ¶ added in v0.2.1
GetAttribute returns an attribute for a given name.
func (Variable) NestedBlocks ¶ added in v0.2.1
func (b Variable) NestedBlocks() []*NestedBlock
NestedBlocks returns all nested blocks.
func (Variable) Raw ¶ added in v0.2.1
Raw returns a raw block instance of hclwrite. It should keep it private if possible, but it's required for some operations.
func (Variable) References ¶ added in v0.2.1
func (b Variable) References() []string
References returns all variable references for all attributes. It returns a unique and sorted list.
func (Variable) RemoveAttribute ¶ added in v0.2.1
func (b Variable) RemoveAttribute(name string)
RemoveAttribute removes an attribute for a given name from the block.
func (Variable) RemoveNestedBlock ¶ added in v0.2.1
func (b Variable) RemoveNestedBlock(nestedBlock Block)
RemoveNestedBlock removes a given nested block from the parent block.
func (Variable) RenameReference ¶ added in v0.2.1
RenameReference renames all variable references for all attributes. The `from` and `to` arguments are specified as dot-delimited resource addresses. The `from` argument can be a partial prefix match, but must match the length of the `to` argument.
func (Variable) SchemaType ¶ added in v0.2.1
func (b Variable) SchemaType() string
SchemaType returns the first label of block. If it does not have a label, return an empty string. Note that it's not the same as the *hclwrite.Block.Type().
func (Variable) SetAttributeRaw ¶ added in v0.2.1
SetAttributeRaw sets an attribute for a given name with raw tokens.
func (Variable) SetAttributeValue ¶ added in v0.2.1
SetAttributeValue sets an attribute for a given name with value.
func (Variable) SetType ¶ added in v0.2.1
func (b Variable) SetType(typeName string)
SetType updates the type name of the block to a given name.
func (Variable) Type ¶ added in v0.2.1
func (b Variable) Type() string
Type returns a type of block.
func (Variable) VerticalFormat ¶ added in v0.2.1
func (b Variable) VerticalFormat()
VerticalFormat formats a body of the block in vertical. Since VerticalFormat clears tokens internally, If you call VerticalFormat each time RemoveNestedBlock is called, the subsequent RemoveNestedBlock will not work properly, so call VerticalFormat only once for each block.