mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
govendor fetch github.com/hashicorp/hcl@99e2f22
This commit is contained in:
19
vendor/github.com/hashicorp/hcl/decoder.go
generated
vendored
19
vendor/github.com/hashicorp/hcl/decoder.go
generated
vendored
@@ -404,20 +404,21 @@ func (d *decoder) decodeMap(name string, node ast.Node, result reflect.Value) er
|
||||
}
|
||||
|
||||
func (d *decoder) decodePtr(name string, node ast.Node, result reflect.Value) error {
|
||||
// lookup the concrete (non pointer) type and decode into that
|
||||
// if the pointer is nil, create an element of the type and set the pointer to that
|
||||
resultType := result.Type()
|
||||
val := reflect.Indirect(result)
|
||||
if val.Kind() == reflect.Invalid || val == reflect.Zero(resultType) {
|
||||
resultElemType := resultType.Elem()
|
||||
val = reflect.New(resultElemType)
|
||||
result.Set(val)
|
||||
// if pointer is not nil, decode into existing value
|
||||
if !result.IsNil() {
|
||||
return d.decode(name, node, result.Elem())
|
||||
}
|
||||
|
||||
// Create an element of the concrete (non pointer) type and decode
|
||||
// into that. Then set the value of the pointer to this type.
|
||||
resultType := result.Type()
|
||||
resultElemType := resultType.Elem()
|
||||
val := reflect.New(resultElemType)
|
||||
if err := d.decode(name, node, reflect.Indirect(val)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result.Set(val)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -516,7 +517,7 @@ func expandObject(node ast.Node, result reflect.Value) ast.Node {
|
||||
// we need to un-flatten the ast enough to decode
|
||||
newNode := &ast.ObjectItem{
|
||||
Keys: []*ast.ObjectKey{
|
||||
&ast.ObjectKey{
|
||||
{
|
||||
Token: keyToken,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user