aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/helper/schema
diff options
context:
space:
mode:
authorAlexandre Garand <alexandre.garand@fretlink.com>2019-08-09 15:59:15 +0200
committerAlexandre Garand <alexandre.garand@fretlink.com>2019-08-09 16:39:21 +0200
commit863486a6b71ed0e562a3965bed56465d007b1418 (patch)
treee93f6a687695af86d54237ec9f575d4ef104222d /vendor/github.com/hashicorp/terraform/helper/schema
parent49c1c7b4dc69ffb9ab52330e6dc52ccdd6351087 (diff)
downloadterraform-provider-statuscake-add_contact_groups.tar.gz
terraform-provider-statuscake-add_contact_groups.tar.zst
terraform-provider-statuscake-add_contact_groups.zip
update vendor and go.modadd_contact_groups
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema')
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/field_reader_config.go3
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go4
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/resource.go22
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/resource_timeout.go4
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/schema.go75
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/shims.go4
6 files changed, 83 insertions, 29 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_config.go b/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_config.go
index 808375c..6ad3f13 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_config.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_config.go
@@ -219,6 +219,9 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult,
219 v, _ := r.Config.Get(key) 219 v, _ := r.Config.Get(key)
220 result[ik] = v 220 result[ik] = v
221 } 221 }
222 case nil:
223 // the map may have been empty on the configuration, so we leave the
224 // empty result
222 default: 225 default:
223 panic(fmt.Sprintf("unknown type: %#v", mraw)) 226 panic(fmt.Sprintf("unknown type: %#v", mraw))
224 } 227 }
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go b/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go
index ae35b4a..3e70acf 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/field_reader_diff.go
@@ -95,7 +95,9 @@ func (r *DiffFieldReader) readMap(
95 return FieldReadResult{}, err 95 return FieldReadResult{}, err
96 } 96 }
97 if source.Exists { 97 if source.Exists {
98 result = source.Value.(map[string]interface{}) 98 // readMap may return a nil value, or an unknown value placeholder in
99 // some cases, causing the type assertion to panic if we don't assign the ok value
100 result, _ = source.Value.(map[string]interface{})
99 resultSet = true 101 resultSet = true
100 } 102 }
101 103
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go
index b5e3065..b59e4e8 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/resource.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource.go
@@ -95,9 +95,10 @@ type Resource struct {
95 // 95 //
96 // Exists is a function that is called to check if a resource still 96 // Exists is a function that is called to check if a resource still
97 // exists. If this returns false, then this will affect the diff 97 // exists. If this returns false, then this will affect the diff
98 // accordingly. If this function isn't set, it will not be called. It 98 // accordingly. If this function isn't set, it will not be called. You
99 // is highly recommended to set it. The *ResourceData passed to Exists 99 // can also signal existence in the Read method by calling d.SetId("")
100 // should _not_ be modified. 100 // if the Resource is no longer present and should be removed from state.
101 // The *ResourceData passed to Exists should _not_ be modified.
101 Create CreateFunc 102 Create CreateFunc
102 Read ReadFunc 103 Read ReadFunc
103 Update UpdateFunc 104 Update UpdateFunc
@@ -329,21 +330,13 @@ func (r *Resource) simpleDiff(
329 c *terraform.ResourceConfig, 330 c *terraform.ResourceConfig,
330 meta interface{}) (*terraform.InstanceDiff, error) { 331 meta interface{}) (*terraform.InstanceDiff, error) {
331 332
332 t := &ResourceTimeout{}
333 err := t.ConfigDecode(r, c)
334
335 if err != nil {
336 return nil, fmt.Errorf("[ERR] Error decoding timeout: %s", err)
337 }
338
339 instanceDiff, err := schemaMap(r.Schema).Diff(s, c, r.CustomizeDiff, meta, false) 333 instanceDiff, err := schemaMap(r.Schema).Diff(s, c, r.CustomizeDiff, meta, false)
340 if err != nil { 334 if err != nil {
341 return instanceDiff, err 335 return instanceDiff, err
342 } 336 }
343 337
344 if instanceDiff == nil { 338 if instanceDiff == nil {
345 log.Printf("[DEBUG] Instance Diff is nil in SimpleDiff()") 339 instanceDiff = terraform.NewInstanceDiff()
346 return nil, err
347 } 340 }
348 341
349 // Make sure the old value is set in each of the instance diffs. 342 // Make sure the old value is set in each of the instance diffs.
@@ -357,10 +350,7 @@ func (r *Resource) simpleDiff(
357 } 350 }
358 } 351 }
359 352
360 if err := t.DiffEncode(instanceDiff); err != nil { 353 return instanceDiff, nil
361 log.Printf("[ERR] Error encoding timeout to instance diff: %s", err)
362 }
363 return instanceDiff, err
364} 354}
365 355
366// Validate validates the resource configuration against the schema. 356// Validate validates the resource configuration against the schema.
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource_timeout.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource_timeout.go
index 9e422c1..222b2cc 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/resource_timeout.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource_timeout.go
@@ -5,7 +5,7 @@ import (
5 "log" 5 "log"
6 "time" 6 "time"
7 7
8 "github.com/hashicorp/terraform/config" 8 "github.com/hashicorp/terraform/config/hcl2shim"
9 "github.com/hashicorp/terraform/terraform" 9 "github.com/hashicorp/terraform/terraform"
10 "github.com/mitchellh/copystructure" 10 "github.com/mitchellh/copystructure"
11) 11)
@@ -70,7 +70,7 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig)
70 case []map[string]interface{}: 70 case []map[string]interface{}:
71 rawTimeouts = raw 71 rawTimeouts = raw
72 case string: 72 case string:
73 if raw == config.UnknownVariableValue { 73 if raw == hcl2shim.UnknownVariableValue {
74 // Timeout is not defined in the config 74 // Timeout is not defined in the config
75 // Defaults will be used instead 75 // Defaults will be used instead
76 return nil 76 return nil
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go
index 6a3c15a..bcc8e4b 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go
@@ -22,7 +22,7 @@ import (
22 "strings" 22 "strings"
23 "sync" 23 "sync"
24 24
25 "github.com/hashicorp/terraform/config" 25 "github.com/hashicorp/terraform/config/hcl2shim"
26 "github.com/hashicorp/terraform/terraform" 26 "github.com/hashicorp/terraform/terraform"
27 "github.com/mitchellh/copystructure" 27 "github.com/mitchellh/copystructure"
28 "github.com/mitchellh/mapstructure" 28 "github.com/mitchellh/mapstructure"
@@ -1365,10 +1365,15 @@ func (m schemaMap) validate(
1365 "%q: this field cannot be set", k)} 1365 "%q: this field cannot be set", k)}
1366 } 1366 }
1367 1367
1368 if raw == config.UnknownVariableValue { 1368 // If the value is unknown then we can't validate it yet.
1369 // If the value is unknown then we can't validate it yet. 1369 // In particular, this avoids spurious type errors where downstream
1370 // In particular, this avoids spurious type errors where downstream 1370 // validation code sees UnknownVariableValue as being just a string.
1371 // validation code sees UnknownVariableValue as being just a string. 1371 // The SDK has to allow the unknown value through initially, so that
1372 // Required fields set via an interpolated value are accepted.
1373 if !isWhollyKnown(raw) {
1374 if schema.Deprecated != "" {
1375 return []string{fmt.Sprintf("%q: [DEPRECATED] %s", k, schema.Deprecated)}, nil
1376 }
1372 return nil, nil 1377 return nil, nil
1373 } 1378 }
1374 1379
@@ -1380,6 +1385,28 @@ func (m schemaMap) validate(
1380 return m.validateType(k, raw, schema, c) 1385 return m.validateType(k, raw, schema, c)
1381} 1386}
1382 1387
1388// isWhollyKnown returns false if the argument contains an UnknownVariableValue
1389func isWhollyKnown(raw interface{}) bool {
1390 switch raw := raw.(type) {
1391 case string:
1392 if raw == hcl2shim.UnknownVariableValue {
1393 return false
1394 }
1395 case []interface{}:
1396 for _, v := range raw {
1397 if !isWhollyKnown(v) {
1398 return false
1399 }
1400 }
1401 case map[string]interface{}:
1402 for _, v := range raw {
1403 if !isWhollyKnown(v) {
1404 return false
1405 }
1406 }
1407 }
1408 return true
1409}
1383func (m schemaMap) validateConflictingAttributes( 1410func (m schemaMap) validateConflictingAttributes(
1384 k string, 1411 k string,
1385 schema *Schema, 1412 schema *Schema,
@@ -1391,7 +1418,7 @@ func (m schemaMap) validateConflictingAttributes(
1391 1418
1392 for _, conflictingKey := range schema.ConflictsWith { 1419 for _, conflictingKey := range schema.ConflictsWith {
1393 if raw, ok := c.Get(conflictingKey); ok { 1420 if raw, ok := c.Get(conflictingKey); ok {
1394 if raw == config.UnknownVariableValue { 1421 if raw == hcl2shim.UnknownVariableValue {
1395 // An unknown value might become unset (null) once known, so 1422 // An unknown value might become unset (null) once known, so
1396 // we must defer validation until it's known. 1423 // we must defer validation until it's known.
1397 continue 1424 continue
@@ -1411,11 +1438,16 @@ func (m schemaMap) validateList(
1411 c *terraform.ResourceConfig) ([]string, []error) { 1438 c *terraform.ResourceConfig) ([]string, []error) {
1412 // first check if the list is wholly unknown 1439 // first check if the list is wholly unknown
1413 if s, ok := raw.(string); ok { 1440 if s, ok := raw.(string); ok {
1414 if s == config.UnknownVariableValue { 1441 if s == hcl2shim.UnknownVariableValue {
1415 return nil, nil 1442 return nil, nil
1416 } 1443 }
1417 } 1444 }
1418 1445
1446 // schemaMap can't validate nil
1447 if raw == nil {
1448 return nil, nil
1449 }
1450
1419 // We use reflection to verify the slice because you can't 1451 // We use reflection to verify the slice because you can't
1420 // case to []interface{} unless the slice is exactly that type. 1452 // case to []interface{} unless the slice is exactly that type.
1421 rawV := reflect.ValueOf(raw) 1453 rawV := reflect.ValueOf(raw)
@@ -1432,6 +1464,15 @@ func (m schemaMap) validateList(
1432 "%s: should be a list", k)} 1464 "%s: should be a list", k)}
1433 } 1465 }
1434 1466
1467 // We can't validate list length if this came from a dynamic block.
1468 // Since there's no way to determine if something was from a dynamic block
1469 // at this point, we're going to skip validation in the new protocol if
1470 // there are any unknowns. Validate will eventually be called again once
1471 // all values are known.
1472 if isProto5() && !isWhollyKnown(raw) {
1473 return nil, nil
1474 }
1475
1435 // Validate length 1476 // Validate length
1436 if schema.MaxItems > 0 && rawV.Len() > schema.MaxItems { 1477 if schema.MaxItems > 0 && rawV.Len() > schema.MaxItems {
1437 return nil, []error{fmt.Errorf( 1478 return nil, []error{fmt.Errorf(
@@ -1489,11 +1530,15 @@ func (m schemaMap) validateMap(
1489 c *terraform.ResourceConfig) ([]string, []error) { 1530 c *terraform.ResourceConfig) ([]string, []error) {
1490 // first check if the list is wholly unknown 1531 // first check if the list is wholly unknown
1491 if s, ok := raw.(string); ok { 1532 if s, ok := raw.(string); ok {
1492 if s == config.UnknownVariableValue { 1533 if s == hcl2shim.UnknownVariableValue {
1493 return nil, nil 1534 return nil, nil
1494 } 1535 }
1495 } 1536 }
1496 1537
1538 // schemaMap can't validate nil
1539 if raw == nil {
1540 return nil, nil
1541 }
1497 // We use reflection to verify the slice because you can't 1542 // We use reflection to verify the slice because you can't
1498 // case to []interface{} unless the slice is exactly that type. 1543 // case to []interface{} unless the slice is exactly that type.
1499 rawV := reflect.ValueOf(raw) 1544 rawV := reflect.ValueOf(raw)
@@ -1620,6 +1665,12 @@ func (m schemaMap) validateObject(
1620 schema map[string]*Schema, 1665 schema map[string]*Schema,
1621 c *terraform.ResourceConfig) ([]string, []error) { 1666 c *terraform.ResourceConfig) ([]string, []error) {
1622 raw, _ := c.Get(k) 1667 raw, _ := c.Get(k)
1668
1669 // schemaMap can't validate nil
1670 if raw == nil {
1671 return nil, nil
1672 }
1673
1623 if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) { 1674 if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) {
1624 return nil, []error{fmt.Errorf( 1675 return nil, []error{fmt.Errorf(
1625 "%s: expected object, got %s", 1676 "%s: expected object, got %s",
@@ -1664,6 +1715,14 @@ func (m schemaMap) validatePrimitive(
1664 raw interface{}, 1715 raw interface{},
1665 schema *Schema, 1716 schema *Schema,
1666 c *terraform.ResourceConfig) ([]string, []error) { 1717 c *terraform.ResourceConfig) ([]string, []error) {
1718
1719 // a nil value shouldn't happen in the old protocol, and in the new
1720 // protocol the types have already been validated. Either way, we can't
1721 // reflect on nil, so don't panic.
1722 if raw == nil {
1723 return nil, nil
1724 }
1725
1667 // Catch if the user gave a complex type where a primitive was 1726 // Catch if the user gave a complex type where a primitive was
1668 // expected, so we can return a friendly error message that 1727 // expected, so we can return a friendly error message that
1669 // doesn't contain Go type system terminology. 1728 // doesn't contain Go type system terminology.
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/shims.go b/vendor/github.com/hashicorp/terraform/helper/schema/shims.go
index 203d017..988573e 100644
--- a/vendor/github.com/hashicorp/terraform/helper/schema/shims.go
+++ b/vendor/github.com/hashicorp/terraform/helper/schema/shims.go
@@ -6,7 +6,7 @@ import (
6 "github.com/zclconf/go-cty/cty" 6 "github.com/zclconf/go-cty/cty"
7 ctyjson "github.com/zclconf/go-cty/cty/json" 7 ctyjson "github.com/zclconf/go-cty/cty/json"
8 8
9 "github.com/hashicorp/terraform/config" 9 "github.com/hashicorp/terraform/config/hcl2shim"
10 "github.com/hashicorp/terraform/configs/configschema" 10 "github.com/hashicorp/terraform/configs/configschema"
11 "github.com/hashicorp/terraform/terraform" 11 "github.com/hashicorp/terraform/terraform"
12) 12)
@@ -50,7 +50,7 @@ func removeConfigUnknowns(cfg map[string]interface{}) {
50 for k, v := range cfg { 50 for k, v := range cfg {
51 switch v := v.(type) { 51 switch v := v.(type) {
52 case string: 52 case string:
53 if v == config.UnknownVariableValue { 53 if v == hcl2shim.UnknownVariableValue {
54 delete(cfg, k) 54 delete(cfg, k)
55 } 55 }
56 case []interface{}: 56 case []interface{}: