hclmarshal

package
v0.0.0-...-5cfaba6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalIntSchema

func MarshalIntSchema(v any, b *Block) error

MarshalIntSchema marshals an intschema struct using reflection.

Types

type Block

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

Block represents a Terraform block, with helpers for adding fields.

func (*Block) Add

func (b *Block) Add(name string, v any)

Add a field to the block that is always marshalled.

func (*Block) AddBlock

func (b *Block) AddBlock(name string) *Block

AddBlock adds a nested block.

func (*Block) AddFuncCall

func (b *Block) AddFuncCall(name string, funcName string, args ...any)

Add a field that is always marshalled and set to the result of a TF function call.

func (*Block) AddNewLine

func (b *Block) AddNewLine()

AddNewLine adds a new line to the block, it's typically used before adding nested blocks, or to separate groups of fields.

func (*Block) AddOptional

func (b *Block) AddOptional(name string, v any)

Add a field to the block that is only marshaled if the value is not empty.

func (*Block) AddRef

func (b *Block) AddRef(name string, id tfid.ID)

AddRef adds a tfid.ID, which may be a hardcoded slug, or a local TF ref. If the ID is empty, then no field is added.

func (*Block) AddRefs

func (b *Block) AddRefs(name string, ids []tfid.ID)

AddRefs adds a list of tfid.ID, supporting mixed lists of hardcoded slugs or local TF refs. If an ID is empty, it is not added to the list. If the list is empty, then no field is added.

func (*Block) AddTFRef

func (b *Block) AddTFRef(name string, ref tfid.Ref)

AddTFRef adds a Terraform reference.

type Marshaler

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

Marshaler is a HCL marshaler.

func New

func New() *Marshaler

New creates a HCL marshaler.

func (*Marshaler) AddData

func (m *Marshaler) AddData(resourceType string, id string) *Block

AddData adds a top-level "data" block to the file.

func (*Marshaler) AddResource

func (m *Marshaler) AddResource(resourceType string, id string) *Block

AddResource adds a top-level "resource" block to the file.

func (*Marshaler) MarshalTo

func (m *Marshaler) MarshalTo(w io.Writer) error

MarshalTo marshals the added resources to the specified writer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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