cfg

package
v0.87.7-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: BSD-3-Clause Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 BuildFieldSelector added in v0.70.0

func BuildFieldSelector(fields []string) string

func CompileRegex

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

func DecodeConfig added in v0.18.0

func DecodeConfig(config any, configJson []byte) error

func GetKafkaClientOAuthTokenSource added in v0.83.0

func GetKafkaClientOAuthTokenSource(ctx context.Context, cfg KafkaClientConfig) (xoauth.TokenSource, error)

func GetKafkaClientOptions added in v0.29.0

func GetKafkaClientOptions(c KafkaClientConfig, l *zap.Logger, tokenSource xoauth.TokenSource) []kgo.Opt

func ListToMap

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

func Parse

func Parse(ptr any, 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 if the child value has zero value 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 ParseNestedFields added in v0.55.0

func ParseNestedFields(fields []string) ([][]string, error)

Parses several fields selectors and removes nested fields. If there are empty field selectors or no selectors at all error returned. For example: {"a", "a.b"} and {"a"} give the same results because field "a.b" is nested to field "a". Used in remove_fields plugin and keep_fields plugin to prevent extra selections.

func ParseSlice

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

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

func SetDefaultValues added in v0.18.0

func SetDefaultValues(data any) error

func VerifyGroupNumbers added in v0.18.0

func VerifyGroupNumbers(groups []int, totalGroups int, logger *zap.Logger) []int

Types

type Base8

type Base8 string

type Config

type Config struct {
	Vault     *VaultConfig
	Pipelines map[string]*PipelineConfig
}

func NewConfig

func NewConfig() *Config

func NewConfigFromFiles added in v0.82.0

func NewConfigFromFiles(paths []string) *Config

type Duration

type Duration string

type Expression

type Expression string

func (*Expression) UnmarshalJSON added in v0.8.9

func (e *Expression) UnmarshalJSON(raw []byte) error

type FieldSelector

type FieldSelector string

type KafkaClientConfig added in v0.29.0

type KafkaClientConfig interface {
	GetBrokers() []string
	GetClientID() string

	IsSaslEnabled() bool
	GetSaslConfig() KafkaClientSaslConfig

	IsSslEnabled() bool
	GetSslConfig() KafkaClientSslConfig
}

type KafkaClientOAuthConfig added in v0.83.0

type KafkaClientOAuthConfig struct {
	// static
	Token string `json:"token"`

	// dynamic
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret"`
	TokenURL     string   `json:"token_url"`
	Scopes       []string `json:"scopes" slice:"true"`
	AuthStyle    string   `json:"auth_style" default:"params" options:"params|header"`

	TLS TLSConfig `json:"tls" child:"true"`
}

type KafkaClientSaslConfig added in v0.29.0

type KafkaClientSaslConfig struct {
	SaslMechanism string
	SaslUsername  string
	SaslPassword  string

	SaslOAuth KafkaClientOAuthConfig
}

type KafkaClientSslConfig added in v0.29.0

type KafkaClientSslConfig struct {
	CACert        string
	ClientCert    string
	ClientKey     string
	SslSkipVerify bool
}

type ListMap

type ListMap string

type MetaTemplates added in v0.26.0

type MetaTemplates map[string]string

type PipelineConfig

type PipelineConfig struct {
	Raw *simplejson.Json
}

type Regexp

type Regexp string

type TLSConfig added in v0.84.1

type TLSConfig struct {
	CACert     string `json:"ca_cert"`
	ClientCert string `json:"client_cert"`
	ClientKey  string `json:"client_key"`
	Insecure   bool   `json:"insecure"`
}

type VaultConfig

type VaultConfig struct {
	Address string

	Token string

	AuthMountPath string
	RoleID        string
	SecretID      string

	TLS *TLSConfig
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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