hclparser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false
View Source
var TerraformOutput bool

Functions

func ConvertExpressionsHcl2HclS

func ConvertExpressionsHcl2HclS(in []hcl.Expression) []hclsyntax.Expression

func PrintAdded

func PrintAdded(mr diff.Diffable, p *PrintParams)

func PrintAttributeContext

func PrintAttributeContext(atdf *AttributesDiff, p *PrintParams)

func PrintModified

func PrintModified(name string, p *PrintParams)

func PrintRemoved

func PrintRemoved(mr diff.Diffable, p *PrintParams)

Types

type Attribute

type Attribute hclsyntax.Attribute

func (Attribute) DiffParam

func (a Attribute) DiffParam() string

func (Attribute) Range

func (a Attribute) Range() hcl.Range

type Attributes

type Attributes struct {
	Mapped hclsyntax.Attributes
	List   []Attribute
}

func NewAttributes

func NewAttributes(attrs hclsyntax.Attributes) *Attributes

func (Attributes) GetDiffables

func (a Attributes) GetDiffables() *[]diff.Diffable

func (Attributes) Len

func (a Attributes) Len() int

func (Attributes) Less

func (a Attributes) Less(i, j int) bool

func (Attributes) Swap

func (a Attributes) Swap(i, j int)

type AttributesDiff

type AttributesDiff struct {
	Changes []ChangedAttributeContext
}

func (*AttributesDiff) Add

func (atdf *AttributesDiff) Add(ctx ChangedAttributeContext)

func (*AttributesDiff) HasChanges

func (atdf *AttributesDiff) HasChanges() bool

type Block

type Block hclsyntax.Block

func (Block) DiffParam

func (b Block) DiffParam() string

func (Block) GetBody

func (b Block) GetBody() *Body

func (Block) Range

func (b Block) Range() hcl.Range

type Blocks

type Blocks hclsyntax.Blocks

func (Blocks) Get

func (b Blocks) Get(i int) *Block

func (Blocks) GetDiffables

func (b Blocks) GetDiffables() *[]diff.Diffable

func (Blocks) Len

func (b Blocks) Len() int

func (Blocks) Less

func (b Blocks) Less(i, j int) bool

func (Blocks) Range

func (b Blocks) Range() hcl.Range

func (Blocks) Swap

func (b Blocks) Swap(i, j int)

type Body

type Body hclsyntax.Body

func (Body) GetBlocks

func (b Body) GetBlocks() Blocks

type ChangedAttributeContext

type ChangedAttributeContext struct {
	//If modificationType is greater than 0 it means that attribute was added
	//If it is less than 0 it - attribute was removed
	//If it equals 0 - attribute value was changed
	//Unchanged attributes should not apppear in this structure
	ModificationType int8
	Orig, Modif      *Attribute
	Diff             *ExpressionDiff
}

type ChangedExprContext

type ChangedExprContext struct {
	//If modificationType is greater than 0 it means that attribute was added
	//If it is less than 0 it - attribute was removed
	//If it equals 0 - attribute value was changed
	//Unchanged attributes should not apppear in this structure
	ModificationType            int8
	Orig, Modified              hclsyntax.Expression
	OrigDiffValue, ModifDiffVal string
}

type Expression

type Expression struct {
	Contained hclsyntax.Expression
}

func (*Expression) DiffParam

func (e *Expression) DiffParam() string

func (*Expression) Range

func (e *Expression) Range() hcl.Range

func (*Expression) StartRange

func (e *Expression) StartRange() hcl.Range

func (*Expression) Value

func (e *Expression) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

func (*Expression) Variables

func (e *Expression) Variables() []hcl.Traversal

type ExpressionDiff

type ExpressionDiff struct {
	Nested  *ExpressionDiff
	Changed bool
	Changes []ChangedExprContext
}

func (*ExpressionDiff) Add

func (edf *ExpressionDiff) Add(ctx ChangedExprContext)

func (*ExpressionDiff) HasChanges

func (edf *ExpressionDiff) HasChanges() bool

type Expressions

type Expressions struct {
	List []Expression
}

func NewHclExpressions

func NewHclExpressions(expressions []hcl.Expression) *Expressions

func NewHclSyntaxExpressions

func NewHclSyntaxExpressions(expressions []hclsyntax.Expression) *Expressions

func (*Expressions) Get

func (e *Expressions) Get(i int) *Expression

func (*Expressions) GetDiffables

func (e *Expressions) GetDiffables() *[]diff.Diffable

func (*Expressions) Len

func (e *Expressions) Len() int

func (*Expressions) Less

func (e *Expressions) Less(i, j int) bool

func (*Expressions) Swap

func (e *Expressions) Swap(i, j int)

type Item

type Item struct {
	Contained hclsyntax.ObjectConsItem
}

func (*Item) DiffParam

func (i *Item) DiffParam() string

func (*Item) Value

func (i *Item) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics)

type Items

type Items struct {
	List []Item
}

func NewItems

func NewItems(items []hclsyntax.ObjectConsItem) *Items

func (*Items) Get

func (items *Items) Get(i int) *Item

func (*Items) GetDiffables

func (items *Items) GetDiffables() *[]diff.Diffable

func (*Items) Len

func (items *Items) Len() int

func (*Items) Less

func (items *Items) Less(i, j int) bool

func (*Items) Swap

func (items *Items) Swap(i, j int)

type ModifiedResources

type ModifiedResources struct {
	// contains filtered or unexported fields
}

func Compare

func Compare(o, m string) (*ModifiedResources, error)

* Compare function performs comparison of 2 files, which it receives as arguments, and returns true if there are no diff o stands for original, m stands for modified It can compare terrafrom files in HCL2 format only If arguments are names of directories, it will try to perform File-by-File comparison

func CompareFiles

func CompareFiles(o, m *os.File) (*ModifiedResources, error)

func NewModifiedResources

func NewModifiedResources() *ModifiedResources

func (*ModifiedResources) Add

func (mr *ModifiedResources) Add(s string)

func (*ModifiedResources) AddAuthor

func (mr *ModifiedResources) AddAuthor(s string)

func (*ModifiedResources) IsEmpty

func (mr *ModifiedResources) IsEmpty() bool

func (*ModifiedResources) List

func (mr *ModifiedResources) List() *[]string

func (*ModifiedResources) ListAuthors

func (mr *ModifiedResources) ListAuthors() *[]string

type PrintParams

type PrintParams struct {
	RemoveColor   *color.Color
	AddColor      *color.Color
	ChangedColor  *color.Color
	OkColor       *color.Color
	CommentColor  *color.Color
	LocationColor *color.Color
	Indent        int
	// contains filtered or unexported fields
}

func GetDefaultPrintParams

func GetDefaultPrintParams() *PrintParams

func (*PrintParams) GetIndentation

func (p *PrintParams) GetIndentation() string

func (*PrintParams) Shift

func (p *PrintParams) Shift()

func (*PrintParams) Unshift

func (p *PrintParams) Unshift()

type SortableFile

type SortableFile struct {
	File *os.File
}

func (SortableFile) DiffParam

func (sf SortableFile) DiffParam() string

type SortableFiles

type SortableFiles []SortableFile

func (SortableFiles) Len

func (sf SortableFiles) Len() int

func (SortableFiles) Less

func (sf SortableFiles) Less(i, j int) bool

func (SortableFiles) Swap

func (sf SortableFiles) Swap(i, j int)

Jump to

Keyboard shortcuts

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