only add "id" to top-level resources
Make sure we only add "id" to the top-level resource, since Resource is also used for nested blocks.
This commit is contained in:
parent
3855b79736
commit
0120d53baf
|
@ -73,7 +73,7 @@ func (s *Schema) coreConfigSchemaAttribute() *configschema.Attribute {
|
||||||
// of Resource, and will panic otherwise.
|
// of Resource, and will panic otherwise.
|
||||||
func (s *Schema) coreConfigSchemaBlock() *configschema.NestedBlock {
|
func (s *Schema) coreConfigSchemaBlock() *configschema.NestedBlock {
|
||||||
ret := &configschema.NestedBlock{}
|
ret := &configschema.NestedBlock{}
|
||||||
if nested := s.Elem.(*Resource).CoreConfigSchema(); nested != nil {
|
if nested := s.Elem.(*Resource).coreConfigSchema(); nested != nil {
|
||||||
ret.Block = *nested
|
ret.Block = *nested
|
||||||
}
|
}
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
|
@ -126,7 +126,7 @@ func (s *Schema) coreConfigSchemaType() cty.Type {
|
||||||
// In practice we don't actually use this for normal schema
|
// In practice we don't actually use this for normal schema
|
||||||
// construction because we construct a NestedBlock in that
|
// construction because we construct a NestedBlock in that
|
||||||
// case instead. See schemaMap.CoreConfigSchema.
|
// case instead. See schemaMap.CoreConfigSchema.
|
||||||
elemType = set.CoreConfigSchema().ImpliedType()
|
elemType = set.coreConfigSchema().ImpliedType()
|
||||||
default:
|
default:
|
||||||
if set != nil {
|
if set != nil {
|
||||||
// Should never happen for a valid schema
|
// Should never happen for a valid schema
|
||||||
|
|
|
@ -304,9 +304,9 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
|
||||||
|
|
||||||
for name, test := range tests {
|
for name, test := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
got := schemaMap(test.Schema).CoreConfigSchema()
|
got := (&Resource{Schema: test.Schema}).CoreConfigSchema()
|
||||||
if !cmp.Equal(got, test.Want, typeComparer) {
|
if !cmp.Equal(got, test.Want, equateEmpty, typeComparer) {
|
||||||
cmp.Diff(got, test.Want, typeComparer)
|
t.Error(cmp.Diff(got, test.Want, equateEmpty, typeComparer))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue