Skip to content

Commit 6d46ef7

Browse files
author
Paddy Carver
committed
Don't always return errors.
We want to return a nil error on successful conversions, not an actual error. Oops.
1 parent e012b8e commit 6d46ef7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tfprotov5/tftypes/value.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,35 @@ func (val Value) As(dst interface{}) error {
5858
return fmt.Errorf("can't unmarshal %s into %T, expected string", val.typ, dst)
5959
}
6060
*target = v
61+
return nil
6162
case *big.Float:
6263
v, ok := val.value.(*big.Float)
6364
if !ok {
6465
return fmt.Errorf("can't unmarshal %s into %T, expected *big.Float", val.typ, dst)
6566
}
6667
target.Set(v)
68+
return nil
6769
case *bool:
6870
v, ok := val.value.(bool)
6971
if !ok {
7072
return fmt.Errorf("can't unmarshal %s into %T, expected boolean", val.typ, dst)
7173
}
7274
*target = v
75+
return nil
7376
case *map[string]Value:
7477
v, ok := val.value.(map[string]Value)
7578
if !ok {
7679
return fmt.Errorf("can't unmarshal %s into %T, expected map[string]tftypes.Value", val.typ, dst)
7780
}
7881
*target = v
82+
return nil
7983
case *[]Value:
8084
v, ok := val.value.([]Value)
8185
if !ok {
8286
return fmt.Errorf("can't unmarshal %s into %T expected []tftypes.Value", val.typ, dst)
8387
}
8488
*target = v
89+
return nil
8590
}
8691
return fmt.Errorf("can't unmarshal into %T, needs UnmarshalTerraform5Type method", dst)
8792
}

0 commit comments

Comments
 (0)