diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/resource.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/resource.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go index c810558..ddba109 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go | |||
@@ -6,6 +6,7 @@ import ( | |||
6 | "log" | 6 | "log" |
7 | "strconv" | 7 | "strconv" |
8 | 8 | ||
9 | "github.com/hashicorp/terraform/config" | ||
9 | "github.com/hashicorp/terraform/terraform" | 10 | "github.com/hashicorp/terraform/terraform" |
10 | ) | 11 | ) |
11 | 12 | ||
@@ -142,6 +143,12 @@ func (r *Resource) Apply( | |||
142 | if err := rt.DiffDecode(d); err != nil { | 143 | if err := rt.DiffDecode(d); err != nil { |
143 | log.Printf("[ERR] Error decoding ResourceTimeout: %s", err) | 144 | log.Printf("[ERR] Error decoding ResourceTimeout: %s", err) |
144 | } | 145 | } |
146 | } else if s != nil { | ||
147 | if _, ok := s.Meta[TimeoutKey]; ok { | ||
148 | if err := rt.StateDecode(s); err != nil { | ||
149 | log.Printf("[ERR] Error decoding ResourceTimeout: %s", err) | ||
150 | } | ||
151 | } | ||
145 | } else { | 152 | } else { |
146 | log.Printf("[DEBUG] No meta timeoutkey found in Apply()") | 153 | log.Printf("[DEBUG] No meta timeoutkey found in Apply()") |
147 | } | 154 | } |
@@ -388,9 +395,25 @@ func (r *Resource) InternalValidate(topSchemaMap schemaMap, writable bool) error | |||
388 | } | 395 | } |
389 | } | 396 | } |
390 | 397 | ||
398 | // Resource-specific checks | ||
399 | for k, _ := range tsm { | ||
400 | if isReservedResourceFieldName(k) { | ||
401 | return fmt.Errorf("%s is a reserved field name for a resource", k) | ||
402 | } | ||
403 | } | ||
404 | |||
391 | return schemaMap(r.Schema).InternalValidate(tsm) | 405 | return schemaMap(r.Schema).InternalValidate(tsm) |
392 | } | 406 | } |
393 | 407 | ||
408 | func isReservedResourceFieldName(name string) bool { | ||
409 | for _, reservedName := range config.ReservedResourceFields { | ||
410 | if name == reservedName { | ||
411 | return true | ||
412 | } | ||
413 | } | ||
414 | return false | ||
415 | } | ||
416 | |||
394 | // Data returns a ResourceData struct for this Resource. Each return value | 417 | // Data returns a ResourceData struct for this Resource. Each return value |
395 | // is a separate copy and can be safely modified differently. | 418 | // is a separate copy and can be safely modified differently. |
396 | // | 419 | // |