body

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectAttributes added in v1.7.0

func CollectAttributes(bodies ...hcl.Body) []*hcl.Attribute

func CollectBlockTypes added in v1.7.0

func CollectBlockTypes(bodies ...hcl.Body) []string

func CollectExpressions added in v1.7.0

func CollectExpressions(bodies ...hcl.Body) []hcl.Expression

func EmptyBody added in v1.7.0

func EmptyBody() hcl.Body

EmptyBody returns a body with no content. This body can be used as a placeholder when a body is required but no body content is available.

func MergeBodies added in v1.7.0

func MergeBodies(bodies ...hcl.Body) hcl.Body

MergeBodies is like MergeFiles except it deals directly with bodies, rather than with entire files.

func New

func New(content *hcl.BodyContent) hcl.Body

func NewContentWithAttr added in v1.9.0

func NewContentWithAttr(attr *hcl.Attribute) *hcl.BodyContent

func NewContentWithAttrName added in v1.9.0

func NewContentWithAttrName(name, value string) *hcl.BodyContent

func RenameAttribute added in v1.10.0

func RenameAttribute(content *hcl.BodyContent, old, new string)

func StringSliceEquals added in v1.10.0

func StringSliceEquals(left, right []string) bool

Types

type Attributes

type Attributes interface {
	JustAllAttributes() []hcl.Attributes
	JustAllAttributesWithName(string) []hcl.Attributes
}

type Body

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

func (*Body) Content

func (e *Body) Content(_ *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics)

func (*Body) JustAttributes

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

func (*Body) MissingItemRange

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

func (*Body) PartialContent

func (e *Body) PartialContent(_ *hcl.BodySchema) (*hcl.BodyContent, hcl.Body, hcl.Diagnostics)

type MergedBodies added in v1.7.0

type MergedBodies []hcl.Body

func (MergedBodies) Content added in v1.7.0

func (mb MergedBodies) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics)

Content returns the content produced by applying the given schema to all of the merged bodies and merging the result.

Although required attributes _are_ supported, they should be used sparingly with merged bodies since in this case there is no contextual information with which to return good diagnostics. Applications working with merged bodies may wish to mark all attributes as optional and then check for required attributes afterwards, to produce better diagnostics.

func (MergedBodies) JustAllAttributes added in v1.7.0

func (mb MergedBodies) JustAllAttributes() []hcl.Attributes

JustAllAttributes returns a list of attributes in order. Since these bodies got added as partialContent we do not have to supply a scheme or handle the underlying diagnostics.

func (MergedBodies) JustAllAttributesWithName added in v1.7.0

func (mb MergedBodies) JustAllAttributesWithName(name string) []hcl.Attributes

JustAllAttributesWithName behaviour is the same as JustAllAttributes with a filtered slice.

func (MergedBodies) JustAttributes added in v1.7.0

func (mb MergedBodies) JustAttributes() (hcl.Attributes, hcl.Diagnostics)

func (MergedBodies) MissingItemRange added in v1.7.0

func (mb MergedBodies) MissingItemRange() hcl.Range

MissingItemRange returns the first non-empty range if any.

func (MergedBodies) PartialContent added in v1.7.0

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

Jump to

Keyboard shortcuts

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