parser

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 6 Imported by: 0

README ΒΆ

Fluent-Bit configuration parser for Golang

github github github

Go package for parsering Fluentbit .conf configuration file.

Read more: Fluentbit Configuration Document

🍭 Features

  • Support Section and Entry objects
  • Support Commands
  • Export all entries of a section into a map object (Section.EntryMap()).

πŸ“¦ Install

go get -u github.com/stevedsun/go-fluentbit-conf-parser

⌨ Usage

package main

import (
	"fmt"
	"os"

	parser "github.com/stevedsun/go-fluentbit-conf-parser"
)

func main() {
	confFile, _ := os.Open("fluentbit.conf")
	defer confFile.Close()

	conf := parser.NewFluentBitConfParser(confFile).Parse()

	for _, include := range conf.Includes {
		fmt.Printf("@INCLUDE %v\n", include)
	}

	for key, value := range conf.Sets {
		fmt.Printf("@SET %v=%v\n", key, value)
	}

	for _, section := range conf.Sections {
		fmt.Printf("[%v]\n", section.Name)
		for _, entry := range section.Entries {
			fmt.Printf("    %v %v\n", entry.Key, entry.Value)
		}
	}
}

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Entry ΒΆ

type Entry struct {
	Key   string
	Value interface{}
}

type FluentBitConf ΒΆ added in v0.1.1

type FluentBitConf struct {
	Sections []Section
	Includes []string
	Sets     map[string]string
}

type FluentBitConfParser ΒΆ

type FluentBitConfParser struct {
	Conf *FluentBitConf
	// contains filtered or unexported fields
}

func NewFluentBitConfParser ΒΆ added in v0.1.1

func NewFluentBitConfParser(reader io.Reader) *FluentBitConfParser

func (*FluentBitConfParser) Parse ΒΆ

func (parser *FluentBitConfParser) Parse() *FluentBitConf

type Section ΒΆ

type Section struct {
	Name    string
	Entries []Entry
}

func NewSection ΒΆ

func NewSection(name string) *Section

func (*Section) EntryMap ΒΆ

func (section *Section) EntryMap() map[string]interface{}

Jump to

Keyboard shortcuts

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