{"modulePath":"github.com/devfile/api/v2","version":"v2.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package attributes\n\n## Types\n\n```go\ntype Attributes map[string]apiext.JSON\n```\nAttributes provides a way to add a map of arbitrary YAML/JSON objects. +kubebuilder:validation:Type=object +kubebuilder:validation:XPreserveUnknownFields\n\n```go\nfunc (attributes Attributes) AsInterface(errorHolder *error) interface{}\n```\nAsInterface allows returning the whole attributes map... as an interface. When the attributes are not empty, the returned interface will be a map of interfaces.\n\nAn optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding\n\n```go\nfunc (attributes Attributes) Booleans(errorHolder *error) map[string]bool\n```\nBooleans allows returning only the attributes whose content is a JSON boolean.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes Attributes) Exists(key string) bool\n```\nExists returns \\`true\\` if the attribute with the given key exists in the attributes map.\n\n```go\nfunc (attributes Attributes) FromBooleanMap(strings map[string]bool) Attributes\n```\nFromBooleanMap allows adding into the current map of attributes all the attributes contained in the given map of booleans\n\n```go\nfunc (attributes Attributes) FromFloatMap(strings map[string]float64) Attributes\n```\nFromFloatMap allows adding into the current map of attributes all the attributes contained in the given map of floats\n\n```go\nfunc (attributes Attributes) FromIntegerMap(strings map[string]int) Attributes\n```\nFromIntegerMap allows adding into the current map of attributes all the attributes contained in the given map of integers\n\n```go\nfunc (attributes Attributes) FromInterface(structure interface{}, errorHolder *error) Attributes\n```\nFromInterface allows completing the map of attributes from the given interface. The given interface, and can be any value that supports Json Marshaling and will be marshalled as a JSON object.\n\nThis is especially useful to create attributes from well-known, but implementation- dependent Go structures.\n\nAn optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding\n\n```go\nfunc (attributes Attributes) FromMap(strings map[string]interface{}, errorHolder *error) Attributes\n```\nFromMap allows adding into the current map of attributes all the attributes contained in the given map of interfaces each attribute of the given map is provided as an interface, and can be any value that supports Json Marshaling.\n\nAn optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding\n\n```go\nfunc (attributes Attributes) FromStringMap(strings map[string]string) Attributes\n```\nFromStringMap allows adding into the current map of attributes all the attributes contained in the given string map\n\n```go\nfunc (attributes Attributes) Get(key string, errorHolder *error) interface{}\n```\nGet allows returning the attribute with the given key as an interface. The underlying type of the returned interface depends on the JSON/YAML content of the attribute. It can be either a simple type like a string, a float64 or a bool, either a structured type like a map of interfaces or an array of interfaces.\n\nAn optional error holder can be passed as an argument to receive any error that might have occurred during the attribute decoding\n\n```go\nfunc (attributes Attributes) GetBoolean(key string, errorHolder *error) bool\n```\nGetBoolean allows returning the attribute with the given key as a bool. If the attribute JSON/YAML content is not a JSON boolean  (or a JSON string that can be converted into a JSON boolean), then the result will be the \\`false\\` zero value and an error is raised.\n\nString values can be converted to boolean values according to the following rules:\n\n\\- strings \"1\", \"t\", \"T\", \"TRUE\", \"true\", and \"True\" will be converted to a \\`true\\` boolean\n\n\\- strings \"0, \"f\", \"F\", \"FALSE\", \"false\", \"False\" will be converted to a \\`false\\` boolean\n\n\\- any other string value will raise an error.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes Attributes) GetInto(key string, into interface{}) error\n```\nGetInto 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.\n\nAn error is returned if the provided interface type is not compatible with the attribute content\n\n```go\nfunc (attributes Attributes) GetNumber(key string, errorHolder *error) float64\n```\nGetNumber allows returning the attribute with the given key as a float64. If the attribute JSON/YAML content is not a JSON number (or a JSON string that can be converted into a JSON number), then the result will be the zero value and an error is raised.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes Attributes) GetString(key string, errorHolder *error) string\n```\nGetString allows returning the attribute with the given key as a string. If the attribute JSON/YAML content is not a JSON string (or a primitive type that can be converted into a string), then the result will be the empty string and an error will be raised.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes Attributes) Into(into interface{}) error\n```\nInto allows decoding the whole attributes map into a given interface. The provided interface should be either a pointer to a struct, or to a map.\n\nAn error is returned if the provided interface type is not compatible with the structure of the attributes\n\n```go\nfunc (attributes Attributes) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements custom JSON marshaling to support free-form attributes\n\n```go\nfunc (attributes Attributes) Numbers(errorHolder *error) map[string]float64\n```\nNumbers allows returning only the attributes whose content is a JSON number.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes Attributes) Put(key string, value interface{}, errorHolder *error) Attributes\n```\nPut allows adding an attribute to the current map of attributes. The attribute is provided as an interface, and can be any value that supports Json Marshaling.\n\nAn optional error holder can be passed as an argument to receive any error that might have occured during the attributes decoding\n\n```go\nfunc (attributes Attributes) PutBoolean(key string, value bool) Attributes\n```\nPutBoolean allows adding a boolean attribute to the current map of attributes\n\n```go\nfunc (attributes Attributes) PutFloat(key string, value float64) Attributes\n```\nPutFloat allows adding a float attribute to the current map of attributes\n\n```go\nfunc (attributes Attributes) PutInteger(key string, value int) Attributes\n```\nPutInteger allows adding an integer attribute to the current map of attributes\n\n```go\nfunc (attributes Attributes) PutString(key string, value string) Attributes\n```\nPutString allows adding a string attribute to the current map of attributes\n\n```go\nfunc (attributes Attributes) Strings(errorHolder *error) map[string]string\n```\nStrings allows returning only the attributes whose content is a JSON string.\n\nAn optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding\n\n```go\nfunc (attributes *Attributes) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements custom JSON unmarshalling to support free-form attributes\n\n```go\ntype KeyNotFoundError struct {\n\tKey string\n}\n```\nKeyNotFoundError returns an error if no key is found for the attribute\n\n```go\nfunc (e *KeyNotFoundError) Error() string\n```\n\n","path":"github.com/devfile/api/v2/pkg/attributes","name":"attributes","synopsis":"","isRedistributable":true}
