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 Parse ¶
Parse decodes YAML bytes into a validated Config.
The decoding pipeline is:
- Strict YAML decode into rawConfig, rejecting unknown top-level and pipeline fields while capturing component entries as raw JSON.
- Parse each component map key as a component identifier (type[/name]).
- 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.
- 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.