utils

package
v1.0.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2019 License: Apache-2.0 Imports: 12 Imported by: 29

Documentation

Index

Constants

View Source
const (
	GlobalValuesKey = "global"
)

Variables

This section is empty.

Functions

func DumpValuesJson

func DumpValuesJson(values Values) ([]byte, error)

func DumpValuesYaml

func DumpValuesYaml(values Values) ([]byte, error)

func ListFullyIn

func ListFullyIn(arr []string, ref []string) bool

ListFullyIn returns whether all 'arr' items contains in `ref` array.

func ListIntersection

func ListIntersection(arrs ...[]string) (result []string)

ListIntersection returns an array with items that are present in all 'arrs' arrays.

func ListSubtract

func ListSubtract(src []string, ignored ...[]string) (result []string)

ListSubtract creates a new array from 'src' array with items that are not present in 'ignored' arrays.

func ModuleNameFromValuesKey

func ModuleNameFromValuesKey(moduleValuesKey string) string

func ModuleNameToValuesKey

func ModuleNameToValuesKey(moduleName string) string

func MustDump

func MustDump(data []byte, err error) []byte

func SortByReference

func SortByReference(in []string, ref []string) []string

SortByReference returns a new array with items sorted by the order of 'ref' array.

func SortReverse

func SortReverse(in []string) []string

SortReverse creates a copy of 'in' array and sort it in a reverse order.

func SortReverseByReference

func SortReverseByReference(in []string, ref []string) []string

SortReverseByReference returns a new array with items, reverse sorted by the order of 'ref' array.

func ValuesToString

func ValuesToString(values Values) string

Types

type ModuleConfig

type ModuleConfig struct {
	ModuleName string
	IsEnabled  bool
	Values     Values
	IsUpdated  bool
}

func NewModuleConfig

func NewModuleConfig(moduleName string) *ModuleConfig

func (*ModuleConfig) FromYaml

func (mc *ModuleConfig) FromYaml(yamlString []byte) (*ModuleConfig, error)

FromYaml loads module config from a yaml string.

func (ModuleConfig) String

func (mc ModuleConfig) String() string

func (*ModuleConfig) WithEnabled

func (mc *ModuleConfig) WithEnabled(v bool) *ModuleConfig

func (*ModuleConfig) WithUpdated

func (mc *ModuleConfig) WithUpdated(v bool) *ModuleConfig

func (*ModuleConfig) WithValues

func (mc *ModuleConfig) WithValues(values map[interface{}]interface{}) (*ModuleConfig, error)

WithValues loads module config from a map.

Values for module in `values` map are addressed by a key. This key should be produced with ModuleNameToValuesKey.

A module is enabled if a key doesn't exist in values.

type Values

type Values map[string]interface{}

Values stores values for modules or hooks by name.

func ApplyJsonPatchToValues

func ApplyJsonPatchToValues(values Values, patch jsonpatch.Patch) (Values, error)

func ApplyValuesPatch

func ApplyValuesPatch(values Values, valuesPatch ValuesPatch) (Values, bool, error)

func FormatValues

func FormatValues(someValues map[interface{}]interface{}) (Values, error)

func MergeValues

func MergeValues(values ...Values) Values

func NewValues

func NewValues(data map[interface{}]interface{}) (Values, error)

func NewValuesFromBytes

func NewValuesFromBytes(data []byte) (Values, error)

type ValuesPatch

type ValuesPatch struct {
	Operations []*ValuesPatchOperation
}

func AppendValuesPatch

func AppendValuesPatch(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch

func CompactValuesPatches

func CompactValuesPatches(valuesPatches []ValuesPatch, newValuesPatch ValuesPatch) []ValuesPatch

func MustValuesPatch

func MustValuesPatch(res *ValuesPatch, err error) *ValuesPatch

func ValuesPatchFromBytes

func ValuesPatchFromBytes(data []byte) (*ValuesPatch, error)

func ValuesPatchFromFile

func ValuesPatchFromFile(filePath string) (*ValuesPatch, error)

func (*ValuesPatch) JsonPatch

func (p *ValuesPatch) JsonPatch() jsonpatch.Patch

type ValuesPatchOperation

type ValuesPatchOperation struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value"`
}

func CompactValuesPatchOperations

func CompactValuesPatchOperations(operations []*ValuesPatchOperation, newOperations []*ValuesPatchOperation) []*ValuesPatchOperation

func (*ValuesPatchOperation) ToString

func (op *ValuesPatchOperation) ToString() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL