MCPcopy Create free account
hub / github.com/devfile/api / GetInto

Method GetInto

pkg/attributes/attributes.go:215–223  ·  view source on GitHub ↗

GetInto allows decoding the attribute with the given key into a given interface. The provided interface should be a pointer to a struct, to an array, or to any simple type. An error is returned if the provided interface type is not compatible with the attribute content

(key string, into interface{})

Source from the content-addressed store, hash-verified

213// An error is returned if the provided interface type is not compatible
214// with the attribute content
215func (attributes Attributes) GetInto(key string, into interface{}) error {
216 var err error
217 if attribute, exists := attributes[key]; exists {
218 err = json.Unmarshal(attribute.Raw, into)
219 } else {
220 err = &KeyNotFoundError{Key: key}
221 }
222 return err
223}
224
225// Strings allows returning only the attributes whose content
226// is a JSON string.

Callers 1

TestDecodeAttributeFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestDecodeAttributeFunction · 0.76