config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: ? modules, 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 configuration loading, parsing, and validation for CoreC.

Package config: secret redaction and sentinel-merge for safe config round-trips.

CoreC exposes the full active configuration via GET /configs/raw so the Dashboard's Config Center can populate its editor with the server's real config. That config contains credentials (api.secret, mqtt passwords, http webhook-secrets, auth headers, …) which must never leak to the operator's browser. Redact replaces every secret VALUE with the SentinelValue ("***") while preserving keys and structure, so the operator sees where secrets are configured without seeing them.

The inverse problem: when the operator submits the (possibly edited) config back via PUT /configs, any unchanged secret still carries "***". A naive full reload would persist the literal "***", breaking credentials. MergeSentinels runs in the executor's Reload path before ApplyConfig: for every secret whose incoming value is exactly SentinelValue, it backfills the real value from the currently active config. Secrets the operator deliberately changed (any value other than "***") pass through untouched.

Index

Constants

View Source
const SentinelValue = "***"

SentinelValue is the placeholder substituted for secret values in the redacted config. The executor's MergeSentinels treats any secret field whose incoming value equals SentinelValue as "unchanged — backfill the live value" during a config reload.

Variables

View Source
var ErrNilConfig = errors.New("config: cannot redact a nil config")

ErrNilConfig is returned by Redact when the input config is nil. The nilnil contract: a nil input has no representation to redact, so Redact must not return a nil value with a nil error — that would let the caller mistake "no config" for "redacted empty config". Callers that expect a nil input (e.g. executor.RawConfigYAML) guard against it before calling.

Functions

func IdleWarnings added in v0.0.4

func IdleWarnings(cfg *core.Config) []string

IdleWarnings returns human-readable, non-blocking warnings for a config that has no data source and/or no transport. These are logged at startup (cmd/corec) and on reload (hub/executor) so an operator sees that the core is running in idle mode and can configure it via the Dashboard. Returns nil for a config that has both a data source and a transport.

func IsSecretSettingKey added in v0.0.4

func IsSecretSettingKey(key string) bool

IsSecretSettingKey reports whether a key names a secret field inside a driver/transport settings map. Exposed for tests and red-team verification.

func Load

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

Load reads, parses, and validates a YAML configuration file. Used at startup (cmd/corec) where there is no current config and no sentinel placeholders, so parse and validate can run inline.

func LoadNoValidate added in v0.0.4

func LoadNoValidate(path string) (*core.Config, error)

LoadNoValidate reads and parses a YAML configuration file WITHOUT running validation. Used by the executor's Reload path, which must run the sentinel-merge (config.MergeSentinels) BETWEEN parse and validate: a config round-tripped from GET /configs/raw carries "***" for unchanged secrets, and validate rejects short sentinels (e.g. api.secret < 8 chars). Merging first restores the real secret values, then Validate runs against the faithful config the operator is about to apply.

func MergeSentinels added in v0.0.4

func MergeSentinels(incoming, current *core.Config)

MergeSentinels replaces every secret value in `incoming` that equals SentinelValue with the corresponding value from `current` (the live config). This allows a redacted config obtained from GET /configs/raw to be round- tripped through PUT /configs without losing credentials: the operator sees "***" for secrets they did not change, and the merge restores the real values before ApplyConfig persists the config.

Rules:

  • incoming secret == "***" AND current has that secret → backfill real value
  • incoming secret == "***" AND current has NO such secret → drop the key (no live credential existed; persisting "***" would be wrong, and an empty value makes any required-credential validation fail loudly instead)
  • incoming secret != "***" (incl. empty / new value) → untouched (operator deliberately changed or cleared it)

`incoming` is mutated in place; it is a freshly parsed config not yet applied, so mutation is safe. `current` is never mutated.

func Parse

func Parse(data []byte) (*core.Config, error)

Parse parses YAML bytes into a Config, running the full validation rules. Used at startup and anywhere a freshly authored config (no sentinel placeholders) is loaded.

func ParseNoValidate added in v0.0.4

func ParseNoValidate(data []byte) (*core.Config, error)

ParseNoValidate parses YAML bytes into a Config WITHOUT running validation.

func Redact added in v0.0.4

func Redact(cfg *core.Config) (*core.Config, error)

Redact returns a deep copy of cfg with every secret value replaced by SentinelValue. The original cfg is never mutated.

Semantics a red-team audit must verify:

  1. A non-empty secret → "***" (presence is visible, value is not).
  2. An empty/absent secret stays empty/absent (no fake "***" injected, so the merge can distinguish "secret configured" from "no secret").
  3. Non-secret fields (broker, host, topic, port, …) are untouched.
  4. The `headers` nested map keeps its keys but every non-empty value → "***".

func Validate added in v0.0.4

func Validate(cfg *core.Config) error

Validate runs the full validation rules against a parsed Config using the global driver and transport registries.

func ValidateWithRegistries added in v0.0.4

func ValidateWithRegistries(cfg *core.Config, drivers DriverRegistry, transports TransportRegistry) error

ValidateWithRegistries runs validation against a Config using the provided driver and transport registries. Used in tests to avoid depending on global registration state (ARCH-002).

Types

type DriverRegistry added in v0.0.4

type DriverRegistry interface {
	RegisteredDrivers() []string
}

DriverRegistry provides access to the set of registered driver types. Implemented by core.Registry or test doubles — eliminates the config package's direct coupling to core.RegisteredDrivers() (ARCH-002).

type TransportRegistry added in v0.0.4

type TransportRegistry interface {
	RegisteredTransports() []string
}

TransportRegistry provides access to the set of registered transport types. Implemented by core.Registry or test doubles — eliminates the config package's direct coupling to core.RegisteredTransports() (ARCH-002).

Jump to

Keyboard shortcuts

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