helper/schema: Rename Timeout resource block to Timeouts (#12533)

helper/schema: Rename Timeout resource block to Timeouts

- Pluralize configuration argument name to better represent that there is
one block for many timeouts
- use a const for the configuration timeouts key
- update docs
This commit is contained in:
Clint 2017-03-09 14:40:14 -06:00 committed by GitHub
parent 3c1ec9ddcd
commit 3fdeacdca7
7 changed files with 15 additions and 10 deletions

View File

@ -622,6 +622,10 @@ resource "aws_db_instance" "bar" {
backup_retention_period = 0
parameter_group_name = "default.mysql5.6"
timeouts {
create = "30m"
}
}`
var testAccAWSDBInstanceConfigKmsKeyId = `

View File

@ -156,7 +156,7 @@ func TestResourceDiff_Timeout_diff(t *testing.T) {
raw, err := config.NewRawConfig(
map[string]interface{}{
"foo": 42,
"timeout": []map[string]interface{}{
"timeouts": []map[string]interface{}{
map[string]interface{}{
"create": "2h",
}},

View File

@ -10,6 +10,7 @@ import (
)
const TimeoutKey = "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0"
const TimeoutsConfigKey = "timeouts"
const (
TimeoutCreate = "create"
@ -60,7 +61,7 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig)
*t = *raw.(*ResourceTimeout)
}
if raw, ok := c.Config["timeout"]; ok {
if raw, ok := c.Config[TimeoutsConfigKey]; ok {
if configTimeouts, ok := raw.([]map[string]interface{}); ok {
for _, timeoutValues := range configTimeouts {
// loop through each Timeout given in the configuration and validate they

View File

@ -63,8 +63,8 @@ func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) {
raw, err := config.NewRawConfig(
map[string]interface{}{
"foo": "bar",
"timeout": c.Config,
"foo": "bar",
TimeoutsConfigKey: c.Config,
})
if err != nil {
t.Fatalf("err: %s", err)
@ -104,7 +104,7 @@ func TestResourceTimeout_ConfigDecode(t *testing.T) {
raw, err := config.NewRawConfig(
map[string]interface{}{
"foo": "bar",
"timeout": []map[string]interface{}{
TimeoutsConfigKey: []map[string]interface{}{
map[string]interface{}{
"create": "2m",
},

View File

@ -1327,7 +1327,7 @@ func (m schemaMap) validateObject(
if m, ok := raw.(map[string]interface{}); ok {
for subk, _ := range m {
if _, ok := schema[subk]; !ok {
if subk == "timeout" {
if subk == TimeoutsConfigKey {
continue
}
es = append(es, fmt.Errorf(

View File

@ -4774,7 +4774,7 @@ func TestSchemaMap_Validate(t *testing.T) {
Err: false,
},
"special timeout field": {
"special timeouts field": {
Schema: map[string]*Schema{
"availability_zone": &Schema{
Type: TypeString,
@ -4785,7 +4785,7 @@ func TestSchemaMap_Validate(t *testing.T) {
},
Config: map[string]interface{}{
"timeout": "bar",
TimeoutsConfigKey: "bar",
},
Err: false,

View File

@ -102,7 +102,7 @@ wildcard (e.g. `"rout*"`) is **not** supported.
### Timeouts
Individual Resources may provide a `timeout` block to enable users to configure the
Individual Resources may provide a `timeouts` block to enable users to configure the
amount of time a specific operation is allowed to take before being considered
an error. For example, the
[aws_db_instance](/docs/providers/aws/r/db_instance.html#timeouts)
@ -122,7 +122,7 @@ resource "aws_db_instance" "timeout_example" {
name = "mydb"
[...]
timeout {
timeouts {
create = "60m"
delete = "2h"
}