Skip to content

Commit

Permalink
Support SchemaFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Jul 11, 2023
1 parent 65e3c0d commit 0f2db7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/tfshim/sdk-v2/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewResource(r *schema.Resource) shim.Resource {
}

func (r v2Resource) Schema() shim.SchemaMap {
return v2SchemaMap(r.tf.Schema)
return v2SchemaMap(r.tf.SchemaMap())
}

func (r v2Resource) SchemaVersion() int {
Expand Down Expand Up @@ -87,8 +87,8 @@ func (r v2Resource) InstanceState(id string, object, meta map[string]interface{}
// them into their TF attribute form. The result is our set of TF attributes.
config := &terraform.ResourceConfig{Raw: object, Config: object}
attributes := map[string]string{}
reader := &schema.ConfigFieldReader{Config: config, Schema: r.tf.Schema}
for k := range r.tf.Schema {
reader := &schema.ConfigFieldReader{Config: config, Schema: r.tf.SchemaMap()}
for k := range r.tf.SchemaMap() {
// Elide nil values.
if v, ok := object[k]; ok && v == nil {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/tfshim/sdk-v2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func makeUnknownElement(elem interface{}) interface{} {
case *schema.Resource:
// If the element uses a resource schema, fill in unknown values for any required properties.
res := make(map[string]interface{})
for k, v := range e.Schema {
for k, v := range e.SchemaMap() {
if v.Required {
res[k] = v2Schema{v}.UnknownValue()
}
Expand Down

0 comments on commit 0f2db7f

Please sign in to comment.