(schema *hcl.BodySchema)
| 90 | } |
| 91 | |
| 92 | func (b *expandBody) extendSchema(schema *hcl.BodySchema) *hcl.BodySchema { |
| 93 | // We augment the requested schema to also include our special "dynamic" |
| 94 | // block type, since then we'll get instances of it interleaved with |
| 95 | // all of the literal child blocks we must also include. |
| 96 | extSchema := &hcl.BodySchema{ |
| 97 | Attributes: schema.Attributes, |
| 98 | Blocks: make([]hcl.BlockHeaderSchema, len(schema.Blocks), len(schema.Blocks)+len(b.hiddenBlocks)+1), |
| 99 | } |
| 100 | copy(extSchema.Blocks, schema.Blocks) |
| 101 | extSchema.Blocks = append(extSchema.Blocks, dynamicBlockHeaderSchema) |
| 102 | |
| 103 | // If we have any hiddenBlocks then we also need to register those here |
| 104 | // so that a call to "Content" on the underlying body won't fail. |
| 105 | // (We'll filter these out again once we process the result of either |
| 106 | // Content or PartialContent.) |
| 107 | for _, blockS := range b.hiddenBlocks { |
| 108 | extSchema.Blocks = append(extSchema.Blocks, blockS) |
| 109 | } |
| 110 | |
| 111 | // If we have any hiddenAttrs then we also need to register these, for |
| 112 | // the same reason as we deal with hiddenBlocks above. |
| 113 | if len(b.hiddenAttrs) != 0 { |
| 114 | newAttrs := make([]hcl.AttributeSchema, len(schema.Attributes), len(schema.Attributes)+len(b.hiddenAttrs)) |
| 115 | copy(newAttrs, extSchema.Attributes) |
| 116 | for name := range b.hiddenAttrs { |
| 117 | newAttrs = append(newAttrs, hcl.AttributeSchema{ |
| 118 | Name: name, |
| 119 | Required: false, |
| 120 | }) |
| 121 | } |
| 122 | extSchema.Attributes = newAttrs |
| 123 | } |
| 124 | |
| 125 | return extSchema |
| 126 | } |
| 127 | |
| 128 | func (b *expandBody) prepareAttributes(rawAttrs hcl.Attributes) hcl.Attributes { |
| 129 | if len(b.hiddenAttrs) == 0 && b.iteration == nil && len(b.valueMarks) == 0 { |
no outgoing calls
no test coverage detected