Skip to content

Commit 8724d55

Browse files
committed
check for required blocks
1 parent 6119dab commit 8724d55

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

internal/plugin/convert/schema.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func ProtoToActionSchema(s *proto.ActionSchema) providers.ActionSchema {
115115
func ProtoToListSchema(s *proto.Schema) providers.Schema {
116116
listSchema := ProtoToProviderSchema(s, nil)
117117
itemCount := 0
118-
// check if the provider has set some attributes as required.
118+
// check if the provider has set some attributes/blocks as required.
119119
// When yes, then we set minItem = 1, which
120120
// validates that the configuration contains a "config" block.
121121
for _, attrS := range listSchema.Body.Attributes {
@@ -124,8 +124,14 @@ func ProtoToListSchema(s *proto.Schema) providers.Schema {
124124
break
125125
}
126126
}
127+
for _, block := range listSchema.Body.BlockTypes {
128+
if block.MinItems > 0 {
129+
itemCount = 1
130+
break
131+
}
132+
}
127133
return providers.Schema{
128-
Version: listSchema.Version,
134+
Version: s.Version,
129135
Body: &configschema.Block{
130136
Attributes: map[string]*configschema.Attribute{
131137
"data": {

internal/plugin6/convert/schema.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func ProtoToActionSchema(s *proto.ActionSchema) providers.ActionSchema {
121121
func ProtoToListSchema(s *proto.Schema) providers.Schema {
122122
listSchema := ProtoToProviderSchema(s, nil)
123123
itemCount := 0
124-
// check if the provider has set some attributes as required.
124+
// check if the provider has set some attributes/blocks as required.
125125
// When yes, then we set minItem = 1, which
126126
// validates that the configuration contains a "config" block.
127127
for _, attrS := range listSchema.Body.Attributes {
@@ -130,6 +130,12 @@ func ProtoToListSchema(s *proto.Schema) providers.Schema {
130130
break
131131
}
132132
}
133+
for _, block := range listSchema.Body.BlockTypes {
134+
if block.MinItems > 0 {
135+
itemCount = 1
136+
break
137+
}
138+
}
133139
return providers.Schema{
134140
Version: listSchema.Version,
135141
Body: &configschema.Block{

0 commit comments

Comments
 (0)