(schema *hcl.BodySchema)
| 50 | } |
| 51 | |
| 52 | func (b *expandBody) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Body, hcl.Diagnostics) { |
| 53 | extSchema := b.extendSchema(schema) |
| 54 | rawContent, _, diags := b.original.PartialContent(extSchema) |
| 55 | // We discard the "remain" argument above because we're going to construct |
| 56 | // our own remain that also takes into account remaining "dynamic" blocks. |
| 57 | |
| 58 | blocks, blockDiags := b.expandBlocks(schema, rawContent.Blocks, true) |
| 59 | diags = append(diags, blockDiags...) |
| 60 | attrs := b.prepareAttributes(rawContent.Attributes) |
| 61 | |
| 62 | content := &hcl.BodyContent{ |
| 63 | Attributes: attrs, |
| 64 | Blocks: blocks, |
| 65 | MissingItemRange: b.original.MissingItemRange(), |
| 66 | } |
| 67 | |
| 68 | remain := &expandBody{ |
| 69 | original: b.original, |
| 70 | forEachCtx: b.forEachCtx, |
| 71 | iteration: b.iteration, |
| 72 | checkForEach: b.checkForEach, |
| 73 | hiddenAttrs: make(map[string]struct{}), |
| 74 | hiddenBlocks: make(map[string]hcl.BlockHeaderSchema), |
| 75 | } |
| 76 | for name := range b.hiddenAttrs { |
| 77 | remain.hiddenAttrs[name] = struct{}{} |
| 78 | } |
| 79 | for typeName, blockS := range b.hiddenBlocks { |
| 80 | remain.hiddenBlocks[typeName] = blockS |
| 81 | } |
| 82 | for _, attrS := range schema.Attributes { |
| 83 | remain.hiddenAttrs[attrS.Name] = struct{}{} |
| 84 | } |
| 85 | for _, blockS := range schema.Blocks { |
| 86 | remain.hiddenBlocks[blockS.Type] = blockS |
| 87 | } |
| 88 | |
| 89 | return content, remain, diags |
| 90 | } |
| 91 | |
| 92 | func (b *expandBody) extendSchema(schema *hcl.BodySchema) *hcl.BodySchema { |
| 93 | // We augment the requested schema to also include our special "dynamic" |
nothing calls this directly
no test coverage detected