MCPcopy
hub / github.com/hashicorp/hcl / Body

Interface Body

structure.go:44–77  ·  structure.go::Body

Body is a container for attributes and blocks. It serves as the primary unit of hierarchical structure within configuration. The content of a body cannot be meaningfully interpreted without a schema, so Body represents the raw body content and has methods that allow the content to be extracted in t

Source from the content-addressed store, hash-verified

42// so Body represents the raw body content and has methods that allow the
43// content to be extracted in terms of a given schema.
44type Body interface {
45 // Content verifies that the entire body content conforms to the given
46 // schema and then returns it, and/or returns diagnostics. The returned
47 // body content is valid if non-nil, regardless of whether Diagnostics
48 // are provided, but diagnostics should still be eventually shown to
49 // the user.
50 Content(schema *BodySchema) (*BodyContent, Diagnostics)
51
52 // PartialContent is like Content except that it permits the configuration
53 // to contain additional blocks or attributes not specified in the
54 // schema. If any are present, the returned Body is non-nil and contains
55 // the remaining items from the body that were not selected by the schema.
56 PartialContent(schema *BodySchema) (*BodyContent, Body, Diagnostics)
57
58 // JustAttributes attempts to interpret all of the contents of the body
59 // as attributes, allowing for the contents to be accessed without a priori
60 // knowledge of the structure.
61 //
62 // The behavior of this method depends on the body's source language.
63 // Some languages, like JSON, can't distinguish between attributes and
64 // blocks without schema hints, but for languages that _can_ error
65 // diagnostics will be generated if any blocks are present in the body.
66 //
67 // Diagnostics may be produced for other reasons too, such as duplicate
68 // declarations of the same attribute.
69 JustAttributes() (Attributes, Diagnostics)
70
71 // MissingItemRange returns a range that represents where a missing item
72 // might hypothetically be inserted. This is used when producing
73 // diagnostics about missing required attributes or blocks. Not all bodies
74 // will have an obvious single insertion point, so the result here may
75 // be rather arbitrary.
76 MissingItemRange() Range
77}
78
79// BodyContent is the result of applying a BodySchema to a Body.
80type BodyContent struct {

Callers 83

TestMergedBodiesContentFunction · 0.65
mergedContentMethod · 0.65
decodeBodyToStructFunction · 0.65
TestBodyContentFunction · 0.65
LoadTestFileMethod · 0.65
decodeTraversalsBlockMethod · 0.65
mergedContentMethod · 0.65
decodeBodyToStructFunction · 0.65
TestBodyContentFunction · 0.65

Implementers 8

Bodyhclsyntax/structure.go
unknownBodyext/dynblock/unknown_body.go
expandBodyext/dynblock/expand_body.go
deepWrapperext/transform/transform.go
diagBodyext/transform/error.go
bodyjson/structure.go
mockBodyhcltest/mock.go

Calls

no outgoing calls

Tested by

no test coverage detected