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

Method AsInterface

pkg/attributes/attributes.go:310–325  ·  view source on GitHub ↗

AsInterface allows returning the whole attributes map... as an interface. When the attributes are not empty, the returned interface will be a map of interfaces. An optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding

(errorHolder *error)

Source from the content-addressed store, hash-verified

308// to receive any error that might have occured during the attributes
309// decoding
310func (attributes Attributes) AsInterface(errorHolder *error) interface{} {
311 rawJSON, err := json.Marshal(attributes)
312 if err != nil && errorHolder != nil {
313 *errorHolder = err
314 return nil
315 }
316
317 container := &[]interface{}{}
318 err = json.Unmarshal([]byte("[ "+string(rawJSON)+" ]"), container)
319 if err != nil && errorHolder != nil {
320 *errorHolder = err
321 return nil
322 }
323
324 return (*container)[0]
325}
326
327// PutString allows adding a string attribute to the
328// current map of attributes

Callers 1

TestDecodeAttributesFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestDecodeAttributesFunction · 0.64