]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/hashicorp/terraform/helper/schema/resource.go
vendor: github.com/hashicorp/terraform/...@v0.10.0
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / helper / schema / resource.go
index c8105588c8e9f9fb4505573d245d6a3a26b05f51..ddba1096d88017b654e63e0dac33923bd7633ae7 100644 (file)
@@ -6,6 +6,7 @@ import (
        "log"
        "strconv"
 
+       "github.com/hashicorp/terraform/config"
        "github.com/hashicorp/terraform/terraform"
 )
 
@@ -142,6 +143,12 @@ func (r *Resource) Apply(
                if err := rt.DiffDecode(d); err != nil {
                        log.Printf("[ERR] Error decoding ResourceTimeout: %s", err)
                }
+       } else if s != nil {
+               if _, ok := s.Meta[TimeoutKey]; ok {
+                       if err := rt.StateDecode(s); err != nil {
+                               log.Printf("[ERR] Error decoding ResourceTimeout: %s", err)
+                       }
+               }
        } else {
                log.Printf("[DEBUG] No meta timeoutkey found in Apply()")
        }
@@ -388,9 +395,25 @@ func (r *Resource) InternalValidate(topSchemaMap schemaMap, writable bool) error
                }
        }
 
+       // Resource-specific checks
+       for k, _ := range tsm {
+               if isReservedResourceFieldName(k) {
+                       return fmt.Errorf("%s is a reserved field name for a resource", k)
+               }
+       }
+
        return schemaMap(r.Schema).InternalValidate(tsm)
 }
 
+func isReservedResourceFieldName(name string) bool {
+       for _, reservedName := range config.ReservedResourceFields {
+               if name == reservedName {
+                       return true
+               }
+       }
+       return false
+}
+
 // Data returns a ResourceData struct for this Resource. Each return value
 // is a separate copy and can be safely modified differently.
 //