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)
- type AnyObject
- type BaseField
- type Field
- type InterfaceTypeHandleFunc
- type InterfaceTypeHandler
- type JSONPatchSpec
- type MergeSource
- type PatchSpec
- type RenderingHandler
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)
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) ResolveFields ¶
func (o *AnyObject) ResolveFields(rc RenderingHandler, depth int, fieldNames ...string) error
func (*AnyObject) UnmarshalYAML ¶
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 { field.BaseField // or *field.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 interface{} `yaml:"value,omitempty" json:"value,omitempty"` }
JSONPatchSpec per rfc6902
type MergeSource ¶
type MergeSource struct { BaseField `yaml:"-" json:"-"` Data interface{} `yaml:"data,omitempty"` }
type PatchSpec ¶
type PatchSpec struct { BaseField // Value for the renderer // // say we have a yaml list ([bar]) stored at https://example.com/dukkha.yaml // // foo@http!: // value: https://example.com/dukkha.yaml // merge: [foo] // // then the resolve value of foo will be [bar, foo] Value *alterInterface `yaml:"value"` // Merge additional data into Value Merge []MergeSource `yaml:"merge,omitempty"` // Patches Value using standard rfc6902 json-patch Patches []JSONPatchSpec `yaml:"patches"` // Unique to make sure elements in the sequence is unique // // only effective when Value is yaml sequence Unique bool `yaml:"unique"` // MapListItemUnique to ensure items are unique in all merged lists respectively // lists with no merge data input are untouched MapListItemUnique bool `yaml:"map_list_item_unique"` // MapListAppend to append lists instead of replacing existing list MapListAppend bool `yaml:"map_list_append"` }
type RenderingHandler ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.