config

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads, normalizes, and validates component manager configuration.

Config can be built from YAML through LoadConfig or ParseConfig, or from embedded defaults through New. All constructor paths normalize component manager implementation names, decode explicit provider config overrides, and complete missing provider configs from the component manager catalog supplied by the caller.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigNotConfigured reports that a nil component manager config was
	// provided where a Config value is required.
	ErrConfigNotConfigured = errors.New("component manager config is not configured")

	// ErrUnknownComponentType reports an unrecognized component type in config.
	ErrUnknownComponentType = cmcatalog.ErrUnknownComponentType

	// ErrComponentManagerImplementationNameEmpty reports that a component type
	// was configured without an implementation name.
	ErrComponentManagerImplementationNameEmpty = cmcatalog.ErrComponentManagerImplementationNameEmpty

	// ErrComponentManagersNotConfigured reports that the service config has no
	// component manager entries.
	ErrComponentManagersNotConfigured = errors.New("component managers are not configured")

	// ErrDuplicateProviderConfig reports duplicate provider configuration after
	// provider names are normalized.
	ErrDuplicateProviderConfig = errors.New("duplicate provider config")

	// ErrProviderConfigDecoderNotRegistered reports that a provider is required
	// but no config decoder is registered for it.
	ErrProviderConfigDecoderNotRegistered = errors.New("provider config decoder is not registered")

	// ErrProviderConfigDecoderRegistryRequired reports that a config operation
	// requires a provider config decoder registry argument.
	ErrProviderConfigDecoderRegistryRequired = errors.New("provider config decoder registry is required")
)

Functions

This section is empty.

Types

type ComponentManagerImplementationNameEmptyError

type ComponentManagerImplementationNameEmptyError = cmcatalog.ComponentManagerImplementationNameEmptyError

ComponentManagerImplementationNameEmptyError includes the component type whose configured implementation name is empty.

type Config

type Config struct {
	// ComponentManagers maps each component type to the component manager
	// implementation responsible for managing that type. Each component manager
	// implementation can use a provider to talk to its external service.
	ComponentManagers map[devicetypes.ComponentType]string

	// ProviderConfigs holds provider-specific typed configs keyed by provider
	// name. Explicit provider configs override defaults; missing providers
	// required by catalog descriptors are completed with provider defaults.
	// Providers are configured once and can be shared by multiple component
	// manager implementations.
	ProviderConfigs map[string]providerapi.ProviderConfig
}

Config holds the component manager configuration.

Config values returned by ParseConfig, LoadConfig, and New are normalized: component manager implementation names are trimmed, unknown component types are rejected, explicit provider names are trimmed, duplicate provider names are rejected after trimming, and missing provider configs required by catalog descriptors are completed from provider defaults.

func LoadConfig

func LoadConfig(
	path string,
	decoders *providerapi.ProviderConfigDecoderRegistry,
	managerCatalog cmcatalog.Catalog,
) (Config, error)

LoadConfig loads the component manager configuration from a YAML file using the supplied provider config decoders and component manager catalog.

func New

func New(
	componentManagers map[devicetypes.ComponentType]string,
	decoders *providerapi.ProviderConfigDecoderRegistry,
	managerCatalog cmcatalog.Catalog,
) (Config, error)

New builds a component manager config from a component-manager implementation map and derives default provider configs from the supplied catalog.

func ParseConfig

func ParseConfig(
	data []byte,
	decoders *providerapi.ProviderConfigDecoderRegistry,
	managerCatalog cmcatalog.Catalog,
) (Config, error)

ParseConfig parses the component manager configuration from YAML data using the supplied provider config decoders and component manager catalog.

func (*Config) HasProvider

func (c *Config) HasProvider(name string) bool

HasProvider checks if a provider is enabled in the configuration.

func (*Config) Validate

func (c *Config) Validate(
	decoders *providerapi.ProviderConfigDecoderRegistry,
	managerCatalog cmcatalog.Catalog,
) error

Validate verifies the generic component manager config contract.

type DuplicateProviderConfigError

type DuplicateProviderConfigError struct {
	// Name is the duplicate provider name after trimming whitespace.
	Name string
}

DuplicateProviderConfigError includes the normalized duplicate provider name.

func (DuplicateProviderConfigError) Error

func (DuplicateProviderConfigError) Is

type ProviderConfigDecoderNotRegisteredError

type ProviderConfigDecoderNotRegisteredError struct {
	// Name is the provider name that has no registered config decoder.
	Name string
	// ComponentType is the component manager type requiring the provider.
	ComponentType devicetypes.ComponentType
	// Implementation is the component manager implementation requiring the
	// provider.
	Implementation string
}

ProviderConfigDecoderNotRegisteredError includes the provider name with no registered config decoder.

func (ProviderConfigDecoderNotRegisteredError) Error

func (ProviderConfigDecoderNotRegisteredError) Is

type RequiredProviderNotConfiguredError added in v1.6.0

type RequiredProviderNotConfiguredError struct {
	// Provider is the provider name required by the component manager.
	Provider string
	// ComponentType is the component manager type requiring the provider.
	ComponentType devicetypes.ComponentType
	// Implementation is the component manager implementation requiring the
	// provider.
	Implementation string
}

RequiredProviderNotConfiguredError includes the required provider and the component manager identity that requires it.

func (RequiredProviderNotConfiguredError) Error added in v1.6.0

func (RequiredProviderNotConfiguredError) Is added in v1.6.0

type UnknownComponentTypeError

type UnknownComponentTypeError = cmcatalog.UnknownComponentTypeError

UnknownComponentTypeError includes the unrecognized component type string.

Jump to

Keyboard shortcuts

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