Documentation ¶
Overview ¶
Package decoder provide a way to decode credentials from a service to a structure It provides a cloud tag to help user match the correct credentials
This is what you can pass as a structure:
// Name is key of a service credentials, decoder will look at any matching credentials which have the key name and will pass the value of this credentials Name string `cloud:"name"` // note: by default if you don't provide a cloud tag the key will be the field name in snake_case Uri decoder.ServiceUri // ServiceUri is a special type. Decoder will expect an uri as a value and will give a ServiceUri User string `cloud:".*user.*,regex"` // by passing `regex` in cloud tag it will say to decoder that the expected key must be match the regex Password string `cloud:".*user.*,regex" cloud-default:"apassword"` // by passing a tag named `cloud-default` decoder will understand that if the key is not found it must fill the field with this value Aslice []string `cloud:"aslice" cloud-default:"value1,value2"` // you can also pass a slice }
Index ¶
- func NewErrDecode(content string) error
- func NewErrTypeNotSupported(field reflect.Value) error
- func Unmarshal(serviceCredentials map[string]interface{}, obj interface{}) error
- func UnmarshalNoDefault(serviceCredentials map[string]interface{}, obj interface{}) error
- func UnmarshalToValue(serviceCredentials map[string]interface{}, ps reflect.Value, noDefaultVal bool) error
- type ErrDecode
- type ErrTypeNotSupported
- type QueryUri
- type ServiceUri
- type Tag
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewErrDecode ¶
func NewErrTypeNotSupported ¶
func UnmarshalNoDefault ¶
UnmarshalNoDefault Decode a map of credentials into a structure without default values
Types ¶
type ErrTypeNotSupported ¶
type ErrTypeNotSupported struct {
// contains filtered or unexported fields
}
func (ErrTypeNotSupported) Error ¶
func (e ErrTypeNotSupported) Error() string
type ServiceUri ¶
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalCloud(data interface{}) error
}
Unmarshaler This interface may be implemented by types to customize their behavior when being unmarshalled from a Map cloud. The UnmarshalCloud method receives a function that may be called to unmarshal the original value into a field or variable. It is safe to call the unmarshal function parameter more than once if necessary.
Click to show internal directories.
Click to hide internal directories.