mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Add some missing Float cases
This commit is contained in:
parent
045e23e55f
commit
18c26cb2eb
@ -82,6 +82,8 @@ func addrToSchema(addr []string, schemaMap map[string]*Schema) []*Schema {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case TypeFloat:
|
||||||
|
fallthrough
|
||||||
case TypeString:
|
case TypeString:
|
||||||
if len(addr) > 0 {
|
if len(addr) > 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -41,10 +41,10 @@ func (r *DiffFieldReader) ReadField(address []string) (FieldReadResult, error) {
|
|||||||
switch schema.Type {
|
switch schema.Type {
|
||||||
case TypeBool:
|
case TypeBool:
|
||||||
fallthrough
|
fallthrough
|
||||||
case TypeFloat:
|
|
||||||
fallthrough
|
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case TypeFloat:
|
||||||
|
fallthrough
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return r.readPrimitive(address, schema)
|
return r.readPrimitive(address, schema)
|
||||||
case TypeList:
|
case TypeList:
|
||||||
|
@ -23,10 +23,10 @@ func (r *MapFieldReader) ReadField(address []string) (FieldReadResult, error) {
|
|||||||
switch schema.Type {
|
switch schema.Type {
|
||||||
case TypeBool:
|
case TypeBool:
|
||||||
fallthrough
|
fallthrough
|
||||||
case TypeFloat:
|
|
||||||
fallthrough
|
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case TypeFloat:
|
||||||
|
fallthrough
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return r.readPrimitive(address, schema)
|
return r.readPrimitive(address, schema)
|
||||||
case TypeList:
|
case TypeList:
|
||||||
|
@ -78,6 +78,8 @@ func (w *MapFieldWriter) set(addr []string, value interface{}) error {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case TypeFloat:
|
||||||
|
fallthrough
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return w.setPrimitive(addr, value, schema)
|
return w.setPrimitive(addr, value, schema)
|
||||||
case TypeList:
|
case TypeList:
|
||||||
@ -235,6 +237,11 @@ func (w *MapFieldWriter) setPrimitive(
|
|||||||
if err := mapstructure.Decode(v, &n); err != nil {
|
if err := mapstructure.Decode(v, &n); err != nil {
|
||||||
return fmt.Errorf("%s: %s", k, err)
|
return fmt.Errorf("%s: %s", k, err)
|
||||||
}
|
}
|
||||||
|
case TypeFloat:
|
||||||
|
var n float64
|
||||||
|
if err := mapstructure.Decode(v, &n); err != nil {
|
||||||
|
return fmt.Errorf("%s: %s", k, err)
|
||||||
|
}
|
||||||
|
|
||||||
set = strconv.FormatInt(int64(n), 10)
|
set = strconv.FormatInt(int64(n), 10)
|
||||||
default:
|
default:
|
||||||
|
@ -78,6 +78,7 @@ type Schema struct {
|
|||||||
//
|
//
|
||||||
// TypeBool - bool
|
// TypeBool - bool
|
||||||
// TypeInt - int
|
// TypeInt - int
|
||||||
|
// TypeFloat - float64
|
||||||
// TypeString - string
|
// TypeString - string
|
||||||
// TypeList - []interface{}
|
// TypeList - []interface{}
|
||||||
// TypeMap - map[string]interface{}
|
// TypeMap - map[string]interface{}
|
||||||
@ -406,6 +407,8 @@ func (m schemaMap) Input(
|
|||||||
fallthrough
|
fallthrough
|
||||||
case TypeInt:
|
case TypeInt:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case TypeFloat:
|
||||||
|
fallthrough
|
||||||
case TypeString:
|
case TypeString:
|
||||||
value, err = m.inputString(input, k, v)
|
value, err = m.inputString(input, k, v)
|
||||||
default:
|
default:
|
||||||
@ -1084,6 +1087,12 @@ func (m schemaMap) validatePrimitive(
|
|||||||
if err := mapstructure.WeakDecode(raw, &n); err != nil {
|
if err := mapstructure.WeakDecode(raw, &n); err != nil {
|
||||||
return nil, []error{err}
|
return nil, []error{err}
|
||||||
}
|
}
|
||||||
|
case TypeFloat:
|
||||||
|
// Verify that we can parse this as an int
|
||||||
|
var n float64
|
||||||
|
if err := mapstructure.WeakDecode(raw, &n); err != nil {
|
||||||
|
return nil, []error{err}
|
||||||
|
}
|
||||||
case TypeString:
|
case TypeString:
|
||||||
// Verify that we can parse this as a string
|
// Verify that we can parse this as a string
|
||||||
var n string
|
var n string
|
||||||
|
Loading…
Reference in New Issue
Block a user