Documentation ¶
Index ¶
- func Register(moduleName string, conversion *Conversion) bool
- func RegisterFunc(moduleName string, srcVersion int, targetVersion int, ...) bool
- type Chain
- func (c *Chain) Add(conversion *Conversion)
- func (c *Chain) Conversion(srcVersion int) *Conversion
- func (c *Chain) ConvertToLatest(fromVersion int, values map[string]interface{}) (int, map[string]interface{}, error)
- func (c *Chain) Count() int
- func (c *Chain) IsKnownVersion(version int) bool
- func (c *Chain) LatestVersion() int
- func (c *Chain) PreviousVersionsList() []int
- func (c *Chain) VersionList() []int
- type ConvRegistry
- type Conversion
- type ConversionFunc
- type Settings
- func (s *Settings) Bytes() []byte
- func (s *Settings) Delete(path string) error
- func (s *Settings) DeleteAndClean(path string) error
- func (s *Settings) DeleteIfEmptyParent(path string) error
- func (s *Settings) Get(path string) gjson.Result
- func (s *Settings) IsEmptyNode(path string) bool
- func (s *Settings) Map() (map[string]interface{}, error)
- func (s *Settings) Set(path string, value interface{}) error
- func (s *Settings) SetFromJSON(path string, jsonRawValue string) error
- func (s *Settings) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(moduleName string, conversion *Conversion) bool
Register adds Conversion implementation to Registry. Returns true to use with "var _ =".
func RegisterFunc ¶
func RegisterFunc(moduleName string, srcVersion int, targetVersion int, conversionFunc ConversionFunc) bool
RegisterFunc adds a function as a Conversion to Registry. Returns true to use with "var _ =".
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is a chain of conversions for module.
func NewNoConvChain ¶
NewNoConvChain return a chain with the latestVersion equal to 1 for modules without registered conversions.
func (*Chain) Add ¶
func (c *Chain) Add(conversion *Conversion)
func (*Chain) Conversion ¶
func (c *Chain) Conversion(srcVersion int) *Conversion
func (*Chain) ConvertToLatest ¶
func (*Chain) IsKnownVersion ¶
IsKnownVersion returns whether version has registered conversion or the latest.
func (*Chain) LatestVersion ¶
func (*Chain) PreviousVersionsList ¶
PreviousVersionsList returns supported previous versions.
func (*Chain) VersionList ¶
VersionList returns all valid versions (all previous and the latest).
type ConvRegistry ¶
type ConvRegistry struct {
// contains filtered or unexported fields
}
func Registry ¶
func Registry() *ConvRegistry
func (*ConvRegistry) Add ¶
func (r *ConvRegistry) Add(moduleName string, conversion *Conversion)
func (*ConvRegistry) Chain ¶
func (r *ConvRegistry) Chain(moduleName string) *Chain
Chain returns a chain with registered conversions or a stub — a chain without conversions with version 1 as the latest.
type Conversion ¶
type Conversion struct { Source int Target int Conversion ConversionFunc }
func NewConversion ¶
func NewConversion(srcVersion int, targetVersion int, conversionFunc ConversionFunc) *Conversion
type ConversionFunc ¶
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings is a helper to simplify module settings manipulation in conversion functions. Access and update map[string]interface{} is difficult, so gjson and sjson come to the rescue.
func SettingsFromBytes ¶
func SettingsFromMap ¶
func SettingsFromString ¶
func SettingsFromYAML ¶
func (*Settings) DeleteAndClean ¶
DeleteAndClean removes path and its empty parents. This method supports only dot separated paths. gjson's selectors and modifiers are not supported.
func (*Settings) DeleteIfEmptyParent ¶
DeleteIfEmptyParent removes field by path if value is an empty object or an empty array.
func (*Settings) IsEmptyNode ¶
IsEmptyNode returns true if value is empty array, or empty map.