hclgen

package
v0.0.0-...-1fa5987 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package hclgen generates formatted HCL from ASTs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributeEquiv

func AttributeEquiv(a, b *hclsyntax.Attribute) bool

func AttributesEquiv

func AttributesEquiv(a, b hclsyntax.Attributes) bool

func BlockEquiv

func BlockEquiv(a, b *hclsyntax.Block) bool

func BlocksEquiv

func BlocksEquiv(a, b hclsyntax.Blocks) bool

func BodyEquiv

func BodyEquiv(a, b hcl.Body) bool

func ExpressionEquiv

func ExpressionEquiv(a, b hcl.Expression) bool

func FileEquiv

func FileEquiv(a, b *hcl.File) bool

func FormatBlock

func FormatBlock(block *hcl.Block) []byte

func FormatExpression

func FormatExpression(x hclsyntax.Expression) []byte

func FormatFile

func FormatFile(f *File) []byte

func LabelsEquiv

func LabelsEquiv(a, b []string) bool

func NewIdentifier

func NewIdentifier(name string, rng hcl.Range) *hclsyntax.ScopeTraversalExpr

func NewNullLiteral

func NewNullLiteral(rng hcl.Range) *hclsyntax.LiteralValueExpr

func NewObjStringKey

func NewObjStringKey(name string, rng hcl.Range) hclsyntax.Expression

func NewStringLiteral

func NewStringLiteral(s string, rng hcl.Range) *hclsyntax.TemplateExpr

func NewTuple

func NewTuple(exprs []hclsyntax.Expression, rng hcl.Range) *hclsyntax.TupleConsExpr

func TokensForExpression

func TokensForExpression(x hclsyntax.Expression) hclwrite.Tokens

func WriteTo

func WriteTo(w io.Writer, f *File) (int64, error)

Writes an HCL file AST to w. Note that syntax trivia (comments and whitespace) are not preserved, and so this function is only appropriate for conversion/generation use cases.

Types

type Attribute

type Attribute = hclsyntax.Attribute

func AttributeFromStructure

func AttributeFromStructure(attribute *hcl.Attribute) *Attribute

type Attributes

type Attributes []*Attribute

func AttributesFromStructure

func AttributesFromStructure(attributes hcl.Attributes) Attributes

func AttributesFromSytnax

func AttributesFromSytnax(attributes hclsyntax.Attributes) Attributes

func (Attributes) Len

func (a Attributes) Len() int

func (Attributes) Less

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

Try to preserve the source code order, but fallback to alphabetical.

func (Attributes) Swap

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

type Block

type Block struct {
	Type   string
	Labels []string
	Body   *Body

	TypeRange       hcl.Range
	LabelRanges     []hcl.Range
	OpenBraceRange  hcl.Range
	CloseBraceRange hcl.Range
}

func BlockFromStructure

func BlockFromStructure(block *hcl.Block) *Block

func BlockFromSyntax

func BlockFromSyntax(block *hclsyntax.Block) *Block

func BlocksFromStructure

func BlocksFromStructure(blocks []*hcl.Block) []*Block

func BlocksFromSyntax

func BlocksFromSyntax(blocks []*hclsyntax.Block) []*Block

func (*Block) SyntaxBlock

func (b *Block) SyntaxBlock() *hclsyntax.Block

type Body

type Body struct {
	Attributes []*hclsyntax.Attribute
	Blocks     []*Block

	SrcRange hcl.Range
	EndRange hcl.Range
}

func BodyFromStructure

func BodyFromStructure(body hcl.Body) *Body

func BodyFromSyntax

func BodyFromSyntax(body *hclsyntax.Body) *Body

func (*Body) Content

func (b *Body) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics)

func (*Body) JustAttributes

func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics)

func (*Body) MissingItemRange

func (b *Body) MissingItemRange() hcl.Range

func (*Body) PartialContent

func (b *Body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Body, hcl.Diagnostics)

func (*Body) SyntaxAttributes

func (b *Body) SyntaxAttributes() hclsyntax.Attributes

func (*Body) SyntaxBlocks

func (b *Body) SyntaxBlocks() []*hclsyntax.Block

func (*Body) SyntaxBody

func (b *Body) SyntaxBody() *hclsyntax.Body

type Expression

type Expression = hclsyntax.Expression

func ExpressionFromStructure

func ExpressionFromStructure(expr hcl.Expression) Expression

type File

type File struct {
	Body *Body
}

func FileFromStructure

func FileFromStructure(file *hcl.File) *File

Jump to

Keyboard shortcuts

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