Documentation ¶
Overview ¶
Package rs provides rendering suffix support for yaml
Index ¶
- Constants
- Variables
- func InitRecursively(fv reflect.Value, h InterfaceTypeHandler)
- func MergeMap(original, additional map[string]interface{}, appendList bool, ...) (map[string]interface{}, error)
- func UniqueList(dt []interface{}) []interface{}
- type AnyObject
- func (o *AnyObject) MarshalJSON() ([]byte, error)
- func (o *AnyObject) MarshalYAML() (interface{}, error)
- func (o *AnyObject) NormalizedValue() interface{}
- func (o *AnyObject) ResolveFields(rc RenderingHandler, depth int, fieldNames ...string) error
- func (o *AnyObject) UnmarshalYAML(n *yaml.Node) error
- type AnyObjectMap
- type BaseField
- type Field
- type InterfaceTypeHandleFunc
- type InterfaceTypeHandler
- type JSONPatchSpec
- type MergeSource
- type RenderingHandler
- type TypeHint
Constants ¶
View Source
const ( TagNameRS = "rs" TagName = TagNameRS )
Variables ¶
View Source
var (
ErrInterfaceTypeNotHandled = errors.New("interface type not handled")
)
Functions ¶
func InitRecursively ¶
func InitRecursively(fv reflect.Value, h InterfaceTypeHandler)
func UniqueList ¶ added in v0.1.1
func UniqueList(dt []interface{}) []interface{}
Types ¶
type AnyObject ¶
type AnyObject struct {
// contains filtered or unexported fields
}
AnyObject is a `interface{}` equivalent with rendering suffix support
func (*AnyObject) MarshalJSON ¶
func (*AnyObject) MarshalYAML ¶
func (*AnyObject) NormalizedValue ¶ added in v0.3.0
func (o *AnyObject) NormalizedValue() interface{}
NormalizedValue returns value with primitive types of the AnyObject that is:
for maps: map[string]interface{} for slices: []interface{} and primitive types for scalar types
should be called after fields being resolved
func (*AnyObject) ResolveFields ¶
func (o *AnyObject) ResolveFields(rc RenderingHandler, depth int, fieldNames ...string) error
func (*AnyObject) UnmarshalYAML ¶
type AnyObjectMap ¶ added in v0.3.0
func (*AnyObjectMap) MarshalJSON ¶ added in v0.3.0
func (aom *AnyObjectMap) MarshalJSON() ([]byte, error)
func (*AnyObjectMap) MarshalYAML ¶ added in v0.3.0
func (aom *AnyObjectMap) MarshalYAML() (interface{}, error)
func (*AnyObjectMap) NormalizedValue ¶ added in v0.3.0
func (aom *AnyObjectMap) NormalizedValue() interface{}
NormalizedValue returns value of the AnyObjectMap with type map[string]interface{}
type BaseField ¶
type BaseField struct {
// contains filtered or unexported fields
}
func (*BaseField) HasUnresolvedField ¶
func (*BaseField) ResolveFields ¶
func (f *BaseField) ResolveFields(rc RenderingHandler, depth int, fieldNames ...string) error
func (*BaseField) UnmarshalYAML ¶
UnmarshalYAML handles parsing of rendering suffix and normal yaml unmarshaling nolint:gocyclo
type Field ¶
type Field interface { yaml.Unmarshaler // ResolveFields resolves yaml fields using rendering suffix // when depth >= 1, resolve inner fields until reaching depth limit // when depth == 0, do nothing // when depth < 0, resolve recursively // // when fieldName is not empty, resolve single field // when fieldName is empty, resolve all fields in the struct ResolveFields(rc RenderingHandler, depth int, fieldNames ...string) error }
func Init ¶
func Init(in Field, h InterfaceTypeHandler) Field
Init the BaseField embedded in your struct, the BaseField must be the first field
type Foo struct { rs.BaseField // or *rs.BaseField }
if the arg `in` doesn't contain BaseField or the BaseField is not the first element it does nothing and will return `in` as is.
type InterfaceTypeHandleFunc ¶
type InterfaceTypeHandler ¶
type JSONPatchSpec ¶
type JSONPatchSpec struct { BaseField `yaml:"-" json:"-"` Operation string `yaml:"op" json:"op"` Path string `yaml:"path" json:"path"` Value AnyObject `yaml:"value,omitempty" json:"value,omitempty"` // Select part of the value for patching // // this action happens before patching Select string `yaml:"select" json:"-"` }
JSONPatchSpec per rfc6902
type MergeSource ¶
type RenderingHandler ¶
Click to show internal directories.
Click to hide internal directories.