// Type asserts the type of an object at the given path. This is useful when // dealing with interfaces which can't be pathed through unless they're // associated with a concrete type. func (loader *Loader) Type(src path.P, name string) { klog.KPrintf("blueprint.loader.type.debug", "src=%s, name=%s", src, name) if value, ok := New(name); !ok { loader.ErrorAt(fmt.Errorf("unknown type '%s'", name), src) } else if err := src.Set(loader.Values, value); err != nil { loader.ErrorAt(err, src) } }
// Add sets the object at the given path to value. func (loader *Loader) Add(src path.P, value interface{}) { klog.KPrintf("blueprint.loader.add.debug", "src=%s, value={%T, %v}", src, value, value) err := src.Set(loader.Values, value) if err == nil { return } if err == path.ErrInvalidType { var typ reflect.Type if typ, err = src.Type(loader.Values); err == nil { if value, err = convert(typ, value); err == nil { err = src.Set(loader.Values, value) } } } loader.ErrorAt(err, src) }