Documentation
¶
Overview ¶
Package inventory computes the static list of configuration keys a dsco-managed struct expects, given a set of layers, without performing any I/O.
See https://github.com/byte4ever/dsco for the parent project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct {
Satisfied *Satisfaction `json:"satisfied,omitempty" yaml:"satisfied,omitempty"`
Key *KeySpec `json:"key,omitempty" yaml:"key,omitempty"`
Path string `json:"path" yaml:"path"`
GoType string `json:"go_type" yaml:"go_type"`
}
Field describes the canonical key (and any baked-in default) for one leaf field of the config struct.
func (Field) MarshalJSON ¶
MarshalJSON implements json.Marshaler so Field keys are emitted in human-readable order: path, go_type, satisfied, key.
func (Field) MarshalYAML ¶
MarshalYAML implements yaml.InterfaceMarshaler so Field keys are emitted in human-readable order: path, go_type, satisfied, key.
type KeySpec ¶
KeySpec is the canonical key form the first string-based layer (in declaration order) that can supply this field would accept.
type Report ¶
type Report struct {
Type string `json:"type" yaml:"type"`
Fields []Field `json:"fields" yaml:"fields"`
}
Report is the static inventory of a config struct against a layer set.
func Compute ¶
Compute walks the model and layer builders exactly like dsco.Fill, but instead of loading values it returns the canonical key each string-based layer would accept for every required leaf field of cfg. No environment variables, command-line arguments, or files are read.
cfg must be **T (pointer to a pointer to a struct), mirroring the Fill calling convention: var c *MyConfig; Compute(&c, layers...).
Pattern: Factory — assembles a Report from model + layers without I/O.
func (*Report) WriteJSON ¶
WriteJSON writes the inventory as JSON via github.com/goccy/go-json. Indentation is two spaces; output ends with a trailing newline.
type Satisfaction ¶
type Satisfaction struct {
Value any `json:"value" yaml:"value"`
LayerID string `json:"layer_id" yaml:"layer_id"`
}
Satisfaction records that a struct layer already provides a value for this field.
func (Satisfaction) MarshalJSON ¶
func (s Satisfaction) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler so Satisfaction.Value is normalized before serialization.
func (Satisfaction) MarshalYAML ¶
func (s Satisfaction) MarshalYAML() (any, error)
MarshalYAML implements yaml.InterfaceMarshaler so Satisfaction.Value is normalized before serialization.