cfg

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B = 1

	// KB ,MB ,GB ,TB ,PB are Decimal
	KB = 1000 * B
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	// KiB ,MiB ,GiB ,TiB ,PiB are Binary
	KiB = 1024 * B
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

Variables

View Source
var DataUnitAliases = map[string]int{
	"kb": KB, "kib": KiB,
	"mb": MB, "mib": MiB,
	"gb": GB, "gib": GiB,
	"tb": TB, "tib": TiB,
	"pb": PB, "pib": PiB,
	"b": B,
}

DataUnitAliases is map to add alias. Alias must not contain space Only lowercase letters should be used in the map, but aliases are case-insensitive

Functions

func CompileRegex

func CompileRegex(s string) (*regexp.Regexp, error)

func ListToMap

func ListToMap(a []string) map[string]bool

func Parse

func Parse(ptr interface{}, values map[string]int) error

Parse holy shit! who write this function?

func ParseChild

func ParseChild(parent reflect.Value, v reflect.Value, values map[string]int) error

it isn't just a recursion it also captures values with the same name from parent i.e. take this config:

{
	"T": 10,
	"Child": { // has `child:true` in a tag
		"T": null
	}
}

this function will set `config.Child.T = config.T` see file.d/cfg/config_test.go:TestHierarchy for an example

func ParseField

func ParseField(v reflect.Value, vField reflect.Value, tField reflect.StructField, values map[string]int) error

func ParseFieldSelector

func ParseFieldSelector(selector string) []string

func ParseSlice

func ParseSlice(v reflect.Value, values map[string]int) error

ParseSlice recursively parses elements of an slice calls Parse, not ParseChild (!)

func UnescapeMap

func UnescapeMap(fields map[string]interface{}) map[string]string

Types

type Base8

type Base8 string

type Config

type Config struct {
	Vault        VaultConfig
	PanicTimeout time.Duration
	Pipelines    map[string]*PipelineConfig
}

func NewConfig

func NewConfig() *Config

func NewConfigFromFile

func NewConfigFromFile(path string) *Config

type Duration

type Duration string

type Expression

type Expression string

type FieldSelector

type FieldSelector string

type ListMap

type ListMap string

type PipelineConfig

type PipelineConfig struct {
	Raw *simplejson.Json
}

type Regexp

type Regexp string

type SubstitutionOp

type SubstitutionOp struct {
	Kind SubstitutionOpKind
	Data []string
}

func ParseSubstitution

func ParseSubstitution(substitution string) ([]SubstitutionOp, error)

type SubstitutionOpKind

type SubstitutionOpKind int
const (
	SubstitutionOpKindRaw SubstitutionOpKind = iota
	SubstitutionOpKindField
)

type VaultConfig

type VaultConfig struct {
	Token     string
	Address   string
	ShouldUse bool
}

Jump to

Keyboard shortcuts

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