fluentbitconfig

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 3

README

go-fluentbit-config

Go Reference

Library to parse Fluent Bit config files. With support for both the classic/legacy mode (INI), and the new YAML config.

go get github.com/calyptia/go-fluentbit-config

Documentation

Index

Constants

View Source
const (
	FormatClassic = "classic"
	FormatYAML    = "yaml"
	FormatJSON    = "json"
)

Variables

View Source
var DefaultSchema = func() Schema {
	var s Schema
	err := json.Unmarshal(rawSchema, &s)
	if err != nil {
		fmt.Fprintf(os.Stderr, "could not parse fluent-bit schema: %v\n", err)
		os.Exit(1)
	}

	s.InjectLTSPlugins()

	return s
}()
View Source
var ErrFormatUnknown = errors.New("format unknown")
View Source
var ErrMissingName = errors.New("missing name property")

Functions

func Name added in v0.7.1

func Name(props property.Properties) string

Name from properties.

func ValidateSection added in v0.7.1

func ValidateSection(kind SectionKind, props property.Properties) error

func ValidateSectionWithSchema added in v0.7.1

func ValidateSectionWithSchema(kind SectionKind, props property.Properties, schema Schema) error

Types

type ByName added in v0.7.0

type ByName map[string]property.Properties

type Config

type Config struct {
	Env      property.Properties `json:"env,omitempty" yaml:"env,omitempty"`
	Includes []string            `json:"includes,omitempty" yaml:"includes,omitempty"`
	Service  property.Properties `json:"service,omitempty" yaml:"service,omitempty"`
	Customs  []ByName            `json:"customs,omitempty" yaml:"customs,omitempty"`
	Pipeline Pipeline            `json:"pipeline,omitempty" yaml:"pipeline,omitempty"`
}

func ParseAs added in v0.7.1

func ParseAs(raw string, format Format) (Config, error)

func (*Config) AddSection added in v0.7.1

func (c *Config) AddSection(kind SectionKind, props property.Properties)

func (Config) DumpAs added in v0.6.1

func (c Config) DumpAs(format Format) (string, error)

func (Config) DumpAsClassic added in v0.7.1

func (c Config) DumpAsClassic() (string, error)

func (Config) DumpAsJSON added in v0.7.1

func (c Config) DumpAsJSON() (string, error)

func (Config) DumpAsYAML added in v0.7.1

func (c Config) DumpAsYAML() (string, error)

func (Config) Equal added in v0.8.0

func (c Config) Equal(target Config) bool

func (*Config) Include added in v0.7.1

func (c *Config) Include(path string)

func (Config) MarshalClassic added in v0.7.1

func (c Config) MarshalClassic() ([]byte, error)

func (*Config) SetEnv added in v0.7.1

func (c *Config) SetEnv(key string, value any)

func (*Config) UnmarshalClassic added in v0.7.1

func (c *Config) UnmarshalClassic(text []byte) error

func (Config) Validate added in v0.2.0

func (c Config) Validate() error

Validate with the default schema.

func (Config) ValidateWithSchema added in v0.2.0

func (c Config) ValidateWithSchema(schema Schema) error

ValidateWithSchema validates that the config satisfies all properties defined on the schema. That is if the schema says the the input plugin "cpu" has a property named "pid" that is of integer type, it must be a valid integer.

type Format added in v0.7.1

type Format string

type LinedError added in v0.7.1

type LinedError struct {
	Msg  string
	Line uint
}

LinedError with information about the line number where the error was found while parsing.

func NewLinedError added in v0.7.1

func NewLinedError(msg string, line uint) *LinedError

func WrapLinedError added in v0.7.1

func WrapLinedError(err error, line uint) *LinedError

func (*LinedError) Error added in v0.7.1

func (e *LinedError) Error() string

type Pipeline added in v0.7.0

type Pipeline struct {
	Inputs  []ByName `json:"inputs,omitempty" yaml:"inputs,omitempty"`
	Parsers []ByName `json:"parsers,omitempty" yaml:"parsers,omitempty"`
	Filters []ByName `json:"filters,omitempty" yaml:"filters,omitempty"`
	Outputs []ByName `json:"outputs,omitempty" yaml:"outputs,omitempty"`
}

type Schema added in v0.2.0

type Schema struct {
	FluentBit SchemaFluentBit `json:"fluent-bit"`
	Customs   []SchemaSection `json:"customs"`
	Inputs    []SchemaSection `json:"inputs"`
	Filters   []SchemaSection `json:"filters"`
	Outputs   []SchemaSection `json:"outputs"`
}

func (*Schema) InjectLTSPlugins added in v0.2.1

func (s *Schema) InjectLTSPlugins()

type SchemaFluentBit added in v0.2.0

type SchemaFluentBit struct {
	Version       string `json:"version"`
	SchemaVersion string `json:"schema_version"`
	OS            string `json:"os"`
}

type SchemaOptions added in v0.2.0

type SchemaOptions struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Default     any    `json:"default,omitempty"`
	Type        string `json:"type"`
}

type SchemaProperties added in v0.2.0

type SchemaProperties struct {
	Options []SchemaOptions `json:"options"`

	// Networking is only present in outputs.
	Networking []SchemaOptions `json:"networking"`
	// NetworkTLS is only present in outputs.
	NetworkTLS []SchemaOptions `json:"network_tls"`
}

type SchemaSection added in v0.2.0

type SchemaSection struct {
	Type        string           `json:"type"`
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Properties  SchemaProperties `json:"properties"`
}

type SectionKind added in v0.7.1

type SectionKind string
const (
	SectionKindService SectionKind = "service"
	SectionKindCustom  SectionKind = "custom"
	SectionKindInput   SectionKind = "input"
	SectionKindParser  SectionKind = "parser"
	SectionKindFilter  SectionKind = "filter"
	SectionKindOutput  SectionKind = "output"
)

func (SectionKind) String added in v0.7.1

func (k SectionKind) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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