Skip to content

Commit 6700deb

Browse files
committed
Fix error when supplying multiple resources to manifest_decode()
1 parent 75fa00f commit 6700deb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

internal/framework/provider/functions/manifest_decode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (f ManifestDecodeFunction) Run(ctx context.Context, req function.RunRequest
5656
return
5757
} else if len(elems) > 1 {
5858
resp.Error = function.NewFuncError("YAML manifest contains multiple resources: use decode_manifest_multi to decode manifests containing more than one resource")
59+
return
5960
}
6061

6162
dynamResp := types.DynamicValue(elems[0])

internal/framework/provider/functions/manifest_decode_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"path"
10+
"regexp"
1011
"testing"
1112

1213
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -44,6 +45,20 @@ func TestManifestDecode(t *testing.T) {
4445
})
4546
}
4647

48+
func TestManifestDecode_ErrorOnMulti(t *testing.T) {
49+
t.Parallel()
50+
51+
resource.UnitTest(t, resource.TestCase{
52+
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
53+
Steps: []resource.TestStep{
54+
{
55+
Config: testManifestDecodeConfig("testdata/decode_multi.yaml"),
56+
ExpectError: regexp.MustCompile(`YAML\s+manifest\s+contains\s+multiple\s+resources`),
57+
},
58+
},
59+
})
60+
}
61+
4762
func testManifestDecodeConfig(filename string) string {
4863
cwd, _ := os.Getwd()
4964
return fmt.Sprintf(`

0 commit comments

Comments
 (0)