builder

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToGenerateSourceFromTemplate indicates a failure in writing the final contents to the destination file
	ErrFailedToGenerateSourceFromTemplate = errors.New("failed to generate source from template")

	// ErrGoNotFound is returned when a Go binary hasn't been found
	ErrGoNotFound = errors.New("Go binary not found")
)
View Source
var ErrInvalidGoMod = errors.New("invalid gomod specification for module")

ErrInvalidGoMod indicates an invalid gomod

Functions

func Compile

func Compile(cfg Config) error

Compile generates a binary from the sources based on the configuration

func Generate

func Generate(cfg Config) error

Generate assembles a new distribution based on the given configuration

func GenerateAndCompile

func GenerateAndCompile(cfg Config) error

GenerateAndCompile will generate the source files based on the given configuration and will compile it into a binary

Types

type Config

type Config struct {
	Logger logr.Logger

	Distribution Distribution `mapstructure:"dist"`
	Exporters    []Module     `mapstructure:"exporters"`
	Extensions   []Module     `mapstructure:"extensions"`
	Receivers    []Module     `mapstructure:"receivers"`
	Processors   []Module     `mapstructure:"processors"`
	Replaces     []string     `mapstructure:"replaces"`
}

Config holds the builder's configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig creates a new config, with default values

func (*Config) ParseModules

func (c *Config) ParseModules() error

ParseModules will parse the Modules entries and populate the missing values

func (Config) Validate

func (c Config) Validate() error

Validate checks whether the current configuration is valid

type Distribution

type Distribution struct {
	Module         string `mapstructure:"module"`
	ExeName        string `mapstructure:"name"`
	Go             string `mapstructure:"go"`
	LongName       string `mapstructure:"description"`
	OtelColVersion string `mapstructure:"otelcol_version"`
	IncludeCore    bool   `mapstructure:"include_core"`
	OutputPath     string `mapstructure:"output_path"`
	Version        string `mapstructure:"version"`
}

Distribution holds the parameters for the final binary

type Module

type Module struct {
	Name   string `mapstructure:"name"`   // if not specified, this is package part of the go mod (last part of the path)
	Import string `mapstructure:"import"` // if not specified, this is the path part of the go mods
	GoMod  string `mapstructure:"gomod"`  // a gomod-compatible spec for the module
	Path   string `mapstructure:"path"`   // an optional path to the local version of this module
	Core   bool   `mapstructure:"core"`   // whether this module comes from core, meaning that no further dependencies will be added
}

Module represents a receiver, exporter, processor or extension for the distribution

Jump to

Keyboard shortcuts

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