configschema

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

ConfigSchema API

This package contains an API that can be used to introspect the configuration struct of a collector component. It can be used to generate documentation or tools to help users configure the collector.

Documentation

Index

Constants

View Source
const DefaultModule = "go.opentelemetry.io/collector"

DefaultModule is the module prefix of otelcol. Can be used to create a DirResolver.

View Source
const DefaultSrcRoot = "."

DefaultSrcRoot is the default root of the collector repo, relative to the current working directory. Can be used to create a DirResolver.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgInfo

type CfgInfo struct {
	// the name of the component group, e.g. "receiver"
	Group string
	// the component type, e.g. "otlpreceiver.Config"
	Type config.Type
	// an instance of the component's configuration struct
	CfgInstance interface{}
}

CfgInfo contains a component config instance, as well as its group name and type.

func GetAllCfgInfos

func GetAllCfgInfos(components component.Factories) []CfgInfo

GetAllCfgInfos accepts a Factories struct, then creates and returns a CfgInfo for each of its components.

func GetCfgInfo

func GetCfgInfo(components component.Factories, componentType, componentName string) (CfgInfo, error)

GetCfgInfo accepts a Factories struct, then creates and returns the default config for the component specified by the passed-in componentType and componentName.

type DirResolver

type DirResolver struct {
	SrcRoot    string
	ModuleName string
}

DirResolver is used to resolve the base directory of a given reflect.Type.

func NewDefaultDirResolver

func NewDefaultDirResolver() DirResolver

NewDefaultDirResolver creates a DirResolver with a default SrcRoot and ModuleName, suitable for using this package's API using otelcol with an executable running from the otelcol's source root (not tests).

func NewDirResolver

func NewDirResolver(srcRoot string, moduleName string) DirResolver

NewDirResolver creates a DirResolver with a custom SrcRoot and ModuleName. Useful for testing and for using this package's API from a repository other than otelcol (e.g. contrib).

func (DirResolver) PackageDir

func (dr DirResolver) PackageDir(t reflect.Type) string

PackageDir accepts a Type and returns its package dir.

type Field

type Field struct {
	Name    string      `yaml:",omitempty"`
	Type    string      `yaml:",omitempty"`
	Kind    string      `yaml:",omitempty"`
	Default interface{} `yaml:",omitempty"`
	Doc     string      `yaml:",omitempty"`
	Fields  []*Field    `yaml:",omitempty"`
}

Field holds attributes and subfields of a config struct.

func ReadFields

func ReadFields(v reflect.Value, dr DirResolver) *Field

ReadFields accepts both a config struct's Value, as well as a DirResolver, and returns a Field pointer for the top level struct as well as all of its recursive subfields.

Jump to

Keyboard shortcuts

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