hclparser

package
v0.0.0-...-503ac3e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0, BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttribute

func AddAttribute(f *hclwrite.File, name string, value string, replace bool) (*hclwrite.File, error)

func CheckAttribute

func CheckAttribute(f *hclwrite.File, name string) bool

func GetAttributeValueAsString

func GetAttributeValueAsString(attr *hclwrite.Attribute) (string, error)

Types

type AttributeAppendFilter

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

AttributeAppendFilter is a filter implementation for appending attribute.

func (*AttributeAppendFilter) Filter

func (f *AttributeAppendFilter) Filter(inFile *hclwrite.File) (*hclwrite.File, error)

Filter reads HCL and appends a new attribute to a given address. If a matched block not found, nothing happens. If the given attribute already exists, it returns an error. If a newline flag is true, it also appends a newline before the new attribute.

type AttributeGetSink

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

AttributeGetSink is a sink implementation for getting a value of attribute.

func (*AttributeGetSink) Sink

func (s *AttributeGetSink) Sink(inFile *hclwrite.File) ([]string, error)

Sink reads HCL and writes value of attribute.

type AttributeSetFilter

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

func (*AttributeSetFilter) Filter

func (f *AttributeSetFilter) Filter(inFile *hclwrite.File) (*hclwrite.File, error)

Filter reads HCL and updates a value of matched an attribute at a given address.

type BlockAppendFilter

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

BlockAppendFilter is a filter implementation for appending block.

func (*BlockAppendFilter) Filter

func (f *BlockAppendFilter) Filter(inFile *hclwrite.File) (*hclwrite.File, error)

Filter reads HCL and appends only matched blocks at a given address. The child address is relative to parent one. If a newline flag is true, it also appends a newline before the new block.

type BlockListSink

type BlockListSink struct{}

BlockListSink is a sink implementation for getting a list of block addresses.

func (*BlockListSink) Sink

func (s *BlockListSink) Sink(inFile *hclwrite.File) ([]string, error)

Sink reads HCL and writes a list of block addresses.

type Filter

type Filter interface {
	// Filter reads HCL and writes HCL
	Filter(*hclwrite.File) (*hclwrite.File, error)
}

func NewAttributeAppendFilter

func NewAttributeAppendFilter(address string, value string, newline bool) Filter

NewAttributeAppendFilter creates a new instance of AttributeAppendFilter.

func NewAttributeSetFilter

func NewAttributeSetFilter(address string, value string) Filter

NewAttributeSetFilter creates a new instance of AttributeSetFilter.

func NewBlockAppendFilter

func NewBlockAppendFilter(parent string, child string, newline bool) Filter

NewBlockAppendFilter creates a new instance of BlockAppendFilter.

type Sink

type Sink interface {
	// Sink reads HCL and writes bytes.
	Sink(*hclwrite.File) ([]string, error)
}

func NewAttributeGetSink

func NewAttributeGetSink(address string) Sink

NewAttributeGetSink creates a new instance of AttributeGetSink.

func NewBlockListSink

func NewBlockListSink() Sink

NewBlockListSink creates a new instance of BlockListSink.

Jump to

Keyboard shortcuts

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