From 545572146e74e09d8f7e52bb469bc24549c24960 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Tue, 15 Nov 2022 15:39:11 -0500 Subject: [PATCH] Document Elem() in the shim --- pkg/tfshim/shim.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/tfshim/shim.go b/pkg/tfshim/shim.go index fa4c70191..9cd0d456f 100644 --- a/pkg/tfshim/shim.go +++ b/pkg/tfshim/shim.go @@ -75,7 +75,20 @@ type Schema interface { Computed() bool ForceNew() bool StateFunc() SchemaStateFunc + + // s.Elem() may return a nil, a Schema value, or a Resource value. + // + // If s represents an element or block of a compound type such TypeList, TypeSet or TypeMap, s.Elem() returns a + // Schema value representing its element type. That is, if s ~ List[String] then s.Elem() ~ String. + // + // If s.Elem() returns a Resource, s represens a configuration block, and s.Elem() Resource only implements the + // Schema field, denoting the schema of the block. + // + // The design of Elem() follows Terraform Plugin SDK directly. + // + // See also: https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/schema/schema.go#L231 Elem() interface{} + MaxItems() int MinItems() int ConflictsWith() []string