Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions builtin/providers/aws/resource_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ resource "aws_db_instance" "bar" {
backup_retention_period = 0

parameter_group_name = "default.mysql5.6"

timeouts {
create = "30m"
}
}`

var testAccAWSDBInstanceConfigKmsKeyId = `
Expand Down
2 changes: 1 addition & 1 deletion helper/schema/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}},
Expand Down
3 changes: 2 additions & 1 deletion helper/schema/resource_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

const TimeoutKey = "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0"
const TimeoutsConfigKey = "timeouts"

const (
TimeoutCreate = "create"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions helper/schema/resource_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
},
Expand Down
2 changes: 1 addition & 1 deletion helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -4785,7 +4785,7 @@ func TestSchemaMap_Validate(t *testing.T) {
},

Config: map[string]interface{}{
"timeout": "bar",
TimeoutsConfigKey: "bar",
},

Err: false,
Expand Down
4 changes: 2 additions & 2 deletions website/source/docs/configuration/resources.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -122,7 +122,7 @@ resource "aws_db_instance" "timeout_example" {
name = "mydb"
[...]

timeout {
timeouts {
create = "60m"
delete = "2h"
}
Expand Down