config

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config provides the configuration loader for the flightctl-catalog-collector. It is part of the public extension foundation: external repositories can import it to build custom collector distributions that register additional source, processor, destination, or extension components.

The loader parses a YAML file into named sources, processors, destinations, and pipelines. Each component map key is a component identifier in the format type[/name]. Provider-specific configuration is captured as opaque JSON for later decoding by the component factory layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeComponent

func DecodeComponent(
	raw json.RawMessage,
	defaults any,
	componentPath string,
) error

DecodeComponent resolves environment-variable references in the raw component body and strict-decodes the result into defaults. defaults must be a pointer to the component's configuration struct, typically obtained from Factory.CreateDefaultConfig. Fields absent from the raw body retain their default values.

The raw body is never modified. The expanded intermediate value is discarded after decoding so resolved values are not retained in the generic collector configuration.

componentPath identifies the configuration location in errors, for example "destinations.flightctl/local".

Types

type ComponentConfig

type ComponentConfig struct {
	ID     catalogcollector.ComponentID
	Config json.RawMessage
}

ComponentConfig holds the parsed component identifier and the opaque provider-specific configuration for a source, processor, destination, or extension.

Config contains the raw JSON body. It is nil when the component has no provider-specific fields.

type Config

type Config struct {
	Service      ServiceConfig
	Sources      map[string]ComponentConfig
	Processors   map[string]ComponentConfig
	Destinations map[string]ComponentConfig
	Extensions   map[string]ComponentConfig
	Pipelines    map[string]PipelineConfig
}

Config is the fully parsed and validated collector configuration. It is not a serialization target; only the intermediate rawConfig and the typed pipeline/component structs carry JSON tags.

func Load

func Load(path string) (*Config, error)

Load reads a YAML configuration file and returns the parsed Config.

func Parse

func Parse(yamlBytes []byte) (*Config, error)

Parse decodes YAML bytes into a validated Config.

The decoding pipeline is:

  1. Strict YAML decode into rawConfig, rejecting unknown top-level and pipeline fields while capturing component entries as raw JSON.
  2. Parse each component map key as a component identifier (type[/name]).
  3. Store each raw JSON body as opaque provider-specific configuration. Environment-variable references (${env:NAME}, ${NAME}) are preserved as-is; resolution is deferred to DecodeComponent.
  4. Validate cross-component references.

Provider type validation, environment expansion, and provider-specific configuration decoding are deferred to the component factory layer through DecodeComponent.

type MetricsConfig

type MetricsConfig struct {
	// Endpoint is the host:port for the Prometheus metrics HTTP server.
	// An empty value defaults to localhost:8888.
	Endpoint string
}

MetricsConfig holds configuration for the internal Prometheus metrics endpoint. When Endpoint is empty, the default localhost:8888 is used. Metrics are disabled only when the entire service.metrics block is absent (i.e. the pointer in ServiceConfig is nil).

type PipelineConfig

type PipelineConfig struct {
	Source      string   `json:"source"`
	Processors  []string `json:"processors,omitempty"`
	Destination string   `json:"destination"`
}

PipelineConfig references a source, an optional ordered list of processors, and a destination by their component identifiers.

type ServiceConfig

type ServiceConfig struct {
	// LogLevel overrides the base logger's level for the lifetime of the
	// collector. Accepted values: debug, info, warn, error. Absent means
	// the caller's logger level is preserved unchanged.
	LogLevel *string

	// Metrics configures the internal Prometheus metrics endpoint.
	// A nil pointer (absent service.metrics block) disables metrics.
	// A non-nil pointer with an empty Endpoint defaults to localhost:8888.
	Metrics *MetricsConfig
}

ServiceConfig holds service-level settings that are applied before any component is constructed. All fields are optional.

type Validator

type Validator interface {
	Validate() error
}

Validator is an optional interface that component configuration structs may implement. If the typed config returned by CreateDefaultConfig implements Validator, DecodeComponent calls Validate after decoding.

Jump to

Keyboard shortcuts

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