mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 19:52:49 -06:00
e91f381cc4
Booleans in the legacy form were stored as strings, and can appear as the incorrect type in the new type system. Unset fields in sets also might show up erroneously in diffs, with equal old and new values.
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func testResourceNested() *schema.Resource {
|
|
return &schema.Resource{
|
|
Create: testResourceNestedCreate,
|
|
Read: testResourceNestedRead,
|
|
Delete: testResourceNestedDelete,
|
|
|
|
Importer: &schema.ResourceImporter{
|
|
State: schema.ImportStatePassthrough,
|
|
},
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
"optional": {
|
|
Type: schema.TypeBool,
|
|
Optional: true,
|
|
ForceNew: true,
|
|
},
|
|
"nested": {
|
|
Type: schema.TypeSet,
|
|
Optional: true,
|
|
ForceNew: true,
|
|
Elem: &schema.Resource{
|
|
Schema: map[string]*schema.Schema{
|
|
"string": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
ForceNew: true,
|
|
},
|
|
"optional": {
|
|
Type: schema.TypeBool,
|
|
Optional: true,
|
|
ForceNew: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func testResourceNestedCreate(d *schema.ResourceData, meta interface{}) error {
|
|
d.SetId(fmt.Sprintf("%x", rand.Int63()))
|
|
return testResourceNestedRead(d, meta)
|
|
}
|
|
|
|
func testResourceNestedRead(d *schema.ResourceData, meta interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
func testResourceNestedDelete(d *schema.ResourceData, meta interface{}) error {
|
|
d.SetId("")
|
|
return nil
|
|
}
|