X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=vendor%2Fgithub.com%2Fhashicorp%2Fterraform%2Fhelper%2Fschema%2Fresource.go;fp=vendor%2Fgithub.com%2Fhashicorp%2Fterraform%2Fhelper%2Fschema%2Fresource.go;h=ddba1096d88017b654e63e0dac33923bd7633ae7;hb=c680a8e1622ed0f18751d9d167c836ee24f5e897;hp=c8105588c8e9f9fb4505573d245d6a3a26b05f51;hpb=38f8880ac81bfabc6d7f82e4dc89661f20fc559e;p=github%2Ffretlink%2Fterraform-provider-statuscake.git 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 ( "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. //