configdata

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package configdata holds the resolved configuration tier consumed by the value binder: scalar values and per-key map values keyed by bindable config keys. Package configengine populates Data while validating loaded files or documents, and package conga folds it into the tier cascade.

Index

Constants

View Source
const ScopeSeparator = " › "

ScopeSeparator separates an origin from its optional scope in rendered provenance.

Variables

This section is empty.

Functions

func JoinOriginScope

func JoinOriginScope(origin, scope string) string

JoinOriginScope joins an origin with its optional scope for display. An empty origin records no provenance detail and ignores the scope.

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data holds the validated configuration tier of one invocation: scalar values and per-key map values, keyed by bindable config key. Later stores overwrite earlier ones in place as files or documents are read.

func New

func New() *Data

New builds an empty configuration data set.

func (*Data) EnsureMap

func (data *Data) EnsureMap(keys []string) map[string]Value

EnsureMap returns the shared per-key map for the given alias keys of a map flag, creating and binding it across all alias keys if not yet present. Calling EnsureMap with an empty map section still records the keys as present for HasKey checks.

func (*Data) HasKey

func (data *Data) HasKey(key string) bool

HasKey reports whether key was set in the configuration tier (as a scalar or as a map section, even an empty one).

func (*Data) Map

func (data *Data) Map(key string) map[string]Value

Map returns the merged per-key map stored under key, or nil when no map was recorded for key.

func (*Data) ScalarValue

func (data *Data) ScalarValue(key string) (Value, bool)

ScalarValue returns the scalar value and its origin stored under key. Consumers that need the provenance — such as the value binder and the programmatic configuration document — prefer it over a raw-string accessor.

func (*Data) SetScalar

func (data *Data) SetScalar(key, raw, origin string)

SetScalar records a scalar value and its origin under key, overwriting any value stored by an earlier file.

func (*Data) SetScalarScoped

func (data *Data) SetScalarScoped(key, raw, origin, scope string)

SetScalarScoped records a scalar value, its origin, and an optional scope within that origin under key, overwriting any value stored by an earlier file. An empty origin records no scope.

type Value

type Value struct {
	// Raw is the stringified value.
	Raw string
	// Origin is the configuration file path that supplied the value;
	// programmatic documents may supply other source labels.
	Origin string
	// Scope names the region within Origin that supplied the value, such as a
	// section of a configuration file. It is empty when Origin is a whole
	// source or none was supplied.
	Scope string
}

Value is a resolved configuration value and the origin that supplied it.

func (Value) SourceDetail

func (v Value) SourceDetail() string

SourceDetail renders the origin with its optional scope for value attribution.

Jump to

Keyboard shortcuts

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