template

package
v4.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigSpec

func ConfigSpec() docs.FieldSpecs

ConfigSpec returns a configuration spec for a template.

func DocsMarkdown

func DocsMarkdown() ([]byte, error)

DocsMarkdown returns a markdown document for the templates documentation.

func FieldConfigSpec

func FieldConfigSpec() docs.FieldSpecs

FieldConfigSpec returns a configuration spec for a field of a template.

func InitNativeTemplates added in v4.3.0

func InitNativeTemplates() (err error)

InitNativeTemplates initialises any templates that were compiled into the binary, these can be found in ./template/embed.go.

func InitTemplates

func InitTemplates(templatesPaths ...string) ([]string, error)

InitTemplates parses and registers native templates, as well as templates at paths provided, and returns any linting errors that occur.

func WithMetricsMapping

func WithMetricsMapping(nm bundle.NewManagement, m *metrics.Mapping) bundle.NewManagement

WithMetricsMapping attempts to wrap the metrics of a manager with a metrics mapping.

Types

type Config

type Config struct {
	Name           string        `yaml:"name"`
	Type           string        `yaml:"type"`
	Status         string        `yaml:"status"`
	Categories     []string      `yaml:"categories"`
	Summary        string        `yaml:"summary"`
	Description    string        `yaml:"description"`
	Fields         []FieldConfig `yaml:"fields"`
	Mapping        string        `yaml:"mapping"`
	MetricsMapping string        `yaml:"metrics_mapping"`
	Tests          []TestConfig  `yaml:"tests"`
}

Config describes a Benthos component template.

func ReadConfig

func ReadConfig(path string) (conf Config, lints []string, err error)

ReadConfig attempts to read a template configuration file.

func (Config) ComponentSpec

func (c Config) ComponentSpec() (docs.ComponentSpec, error)

ComponentSpec creates a documentation component spec from a template config.

func (Config) Test

func (c Config) Test() ([]string, error)

Test ensures that the template compiles, and executes any unit test definitions within the config.

type FieldConfig

type FieldConfig struct {
	Name        string       `yaml:"name"`
	Description string       `yaml:"description"`
	Type        *string      `yaml:"type,omitempty"`
	Kind        *string      `yaml:"kind,omitempty"`
	Default     *interface{} `yaml:"default,omitempty"`
	Advanced    bool         `yaml:"advanced"`
}

FieldConfig describes a configuration field used in the template.

func (FieldConfig) FieldSpec

func (c FieldConfig) FieldSpec() (docs.FieldSpec, error)

FieldSpec creates a documentation field spec from a template field config.

type TestConfig

type TestConfig struct {
	Name     string    `yaml:"name"`
	Config   yaml.Node `yaml:"config"`
	Expected yaml.Node `yaml:"expected,omitempty"`
}

TestConfig defines a unit test for the template.

Jump to

Keyboard shortcuts

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