|
|
|
|
@ -5,6 +5,7 @@ package testing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"maps"
|
|
|
|
|
"path"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
|
@ -20,6 +21,76 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// withBlockTypeAttributes contains additional block type attributes that are used across
|
|
|
|
|
// different resources and types, so this function serves as a place to store the shared attributes.
|
|
|
|
|
withBlockTypeAttributes = func(original map[string]*configschema.Attribute) map[string]*configschema.Attribute {
|
|
|
|
|
attrs := map[string]*configschema.Attribute{
|
|
|
|
|
"list_value": {
|
|
|
|
|
Type: cty.List(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
"set_value": {
|
|
|
|
|
Type: cty.Set(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
"map_value": {
|
|
|
|
|
Type: cty.Map(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// The below nested_* attributes represent config supporting
|
|
|
|
|
// attributes as nested blocks, where terraform interprets the nested blocks
|
|
|
|
|
// as attributes within the schema
|
|
|
|
|
"nested_list_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingList,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"nested_set_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingSet,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"nested_map_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingMap,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
maps.Copy(original, attrs)
|
|
|
|
|
return original
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProviderSchema = &providers.GetProviderSchemaResponse{
|
|
|
|
|
Provider: providers.Schema{
|
|
|
|
|
Body: &configschema.Block{
|
|
|
|
|
@ -44,6 +115,20 @@ var (
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"test_complex_resource": {
|
|
|
|
|
Body: &configschema.Block{
|
|
|
|
|
Attributes: withBlockTypeAttributes(map[string]*configschema.Attribute{
|
|
|
|
|
"id": {Type: cty.String, Optional: true, Computed: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
"interrupt_count": {Type: cty.Number, Optional: true},
|
|
|
|
|
"destroy_fail": {Type: cty.Bool, Optional: true, Computed: true},
|
|
|
|
|
"create_wait_seconds": {Type: cty.Number, Optional: true},
|
|
|
|
|
"destroy_wait_seconds": {Type: cty.Number, Optional: true},
|
|
|
|
|
"write_only": {Type: cty.String, Optional: true, WriteOnly: true},
|
|
|
|
|
"defer": {Type: cty.Bool, Optional: true},
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
DataSources: map[string]providers.Schema{
|
|
|
|
|
"test_data_source": {
|
|
|
|
|
@ -69,73 +154,11 @@ var (
|
|
|
|
|
|
|
|
|
|
"test_complex_data_source": {
|
|
|
|
|
Body: &configschema.Block{
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
Attributes: withBlockTypeAttributes(map[string]*configschema.Attribute{
|
|
|
|
|
"id": {Type: cty.String, Required: true},
|
|
|
|
|
"value": {Type: cty.String, Computed: true},
|
|
|
|
|
"write_only": {Type: cty.String, Optional: true, WriteOnly: true},
|
|
|
|
|
|
|
|
|
|
"list_value": {
|
|
|
|
|
Type: cty.List(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
"set_value": {
|
|
|
|
|
Type: cty.Set(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
"map_value": {
|
|
|
|
|
Type: cty.Map(cty.Object(map[string]cty.Type{
|
|
|
|
|
"name": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
})),
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// The below nested_* attributes represent config supporting
|
|
|
|
|
// attributes as nested blocks, where terraform interprets the nested blocks
|
|
|
|
|
// as attributes within the schema
|
|
|
|
|
"nested_list_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingList,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"nested_set_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingSet,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"nested_map_value": {
|
|
|
|
|
Computed: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
NestedType: &configschema.Object{
|
|
|
|
|
Nesting: configschema.NestingMap,
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"name": {Type: cty.String, Optional: true},
|
|
|
|
|
"value": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// We never actually reference these values from a data
|
|
|
|
|
// source, but we have tests that use the same cty.Value
|
|
|
|
|
// to represent a test_resource and a test_data_source
|
|
|
|
|
@ -146,7 +169,7 @@ var (
|
|
|
|
|
"create_wait_seconds": {Type: cty.Number, Computed: true},
|
|
|
|
|
"destroy_wait_seconds": {Type: cty.Number, Computed: true},
|
|
|
|
|
"defer": {Type: cty.Bool, Computed: true},
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|