From 992cddeaed07f953efdc0b21ba230ce79fa57d35 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 5 Sep 2023 14:26:06 +0100 Subject: [PATCH] schemahelper: Make dynamic block content block required (#314) --- decoder/body_extensions_test.go | 2 +- decoder/hover_test.go | 2 +- decoder/internal/schemahelper/dynamic_block.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/decoder/body_extensions_test.go b/decoder/body_extensions_test.go index b3bb7208..74085096 100644 --- a/decoder/body_extensions_test.go +++ b/decoder/body_extensions_test.go @@ -1900,7 +1900,7 @@ resource "aws_elastic_beanstalk_environment" "example" { Value: "The body of each generated block", Kind: lang.PlainTextKind, }, - Detail: "Block, max: 1", + Detail: "Block, min: 1, max: 1", Kind: lang.BlockCandidateKind, TextEdit: lang.TextEdit{ Range: hcl.Range{ diff --git a/decoder/hover_test.go b/decoder/hover_test.go index eaa473b4..88f6a3cc 100644 --- a/decoder/hover_test.go +++ b/decoder/hover_test.go @@ -1500,7 +1500,7 @@ func TestDecoder_HoverAtPos_extensions_dynamic(t *testing.T) { hcl.Pos{Line: 5, Column: 13, Byte: 102}, &lang.HoverData{ Content: lang.MarkupContent{ - Value: "**content** _Block, max: 1_\n\n" + + Value: "**content** _Block, min: 1, max: 1_\n\n" + "The body of each generated block", Kind: lang.MarkdownKind, }, diff --git a/decoder/internal/schemahelper/dynamic_block.go b/decoder/internal/schemahelper/dynamic_block.go index 318e0455..81f9ae3f 100644 --- a/decoder/internal/schemahelper/dynamic_block.go +++ b/decoder/internal/schemahelper/dynamic_block.go @@ -20,6 +20,7 @@ func buildDynamicBlockSchema(inputSchema *schema.BodySchema) *schema.BlockSchema Blocks: map[string]*schema.BlockSchema{ "content": { Description: lang.PlainText("The body of each generated block"), + MinItems: 1, MaxItems: 1, Body: block.Body.Copy(), },