refactor(configuration): delete the dead runtime config overlay

The file overlay path has folded partial map-valued entries since
b1d28164, answering xrux's open question: a decode that zeroes omitted
fields is the old behaviour, kept only by the now callerless runtime
overlay. Loader.ApplyOverlay, ApplyOverlayValues and
applySchedulingOverlay had no callers anywhere in the tree, so the fold
machinery stays and the dead runtime path goes.
This commit is contained in:
sam committed 2026-10-05 19:21:05 +11:00
1 parent 95ea7aa6f9
commit 0ec8e6f272
3 files changed
-49

No files matched your search

@@ -7,19 +7,8 @@ import (
"strings"
"gopkg.in/yaml.v3"
"github.com/samcharles93/archie-core/internal/config"
)
// ApplyOverlayValues decodes a nested map of overrides into cfg, replacing
// only the keys present. overrides is not mutated.
func ApplyOverlayValues(cfg *config.Config, overrides map[string]any) error {
if len(overrides) == 0 {
return nil
}
return applyOverlayMapping(cfg, overrides)
}
// applyOverlayFile layers the overlay file at path over target and returns
// the file's unconsumed keys.
func applyOverlayFile(path string, target any) ([]string, error) {
@@ -141,25 +141,6 @@ func (l *Loader) Overlay(basePath, overlayPath string) (*Document, error) {
return l.overlayFile(basePath, overlayPath)
}
// ApplyOverlay layers runtime overrides over a copy of doc, then defaults and
// validates. doc is not mutated.
func (l *Loader) ApplyOverlay(doc *Document, overrides map[string]any) (*Document, error) {
next := *doc
next.Config = doc.Config.Clone()
next.Provenance.Origins = append([]Origin(nil), doc.Provenance.Origins...)
if len(overrides) == 0 {
return l.finalize(&next, Validate)
}
if err := ApplyOverlayValues(&next.Config, overrides); err != nil {
return nil, err
}
if err := applySchedulingOverlay(&next.Scheduling, overrides); err != nil {
return nil, err
}
next.Provenance.record(Origin{Path: "config_overlay (runtime)", Role: RoleMain, Layer: LayerOverlay})
return l.finalize(&next, Validate)
}
func (l *Loader) overlayFile(basePath, overlayPath string) (*Document, error) {
doc := &Document{}
@@ -1,10 +1,7 @@
package configuration
import (
"fmt"
"time"
"gopkg.in/yaml.v3"
)
// SchedulingInput is the external [scheduling] input document. It deliberately
@@ -56,19 +53,3 @@ func decodeSchedulingFileKeys(path string, target *SchedulingInput) ([]string, e
*target = doc.Scheduling
return keys, nil
}
func applySchedulingOverlay(target *SchedulingInput, overrides map[string]any) error {
if len(overrides) == 0 {
return nil
}
data, err := yaml.Marshal(overrides)
if err != nil {
return fmt.Errorf("%w: encoding scheduling overlay: %w", ErrUnreadable, err)
}
doc := schedulingDocument{Scheduling: *target}
if err := yaml.Unmarshal(data, &doc); err != nil {
return fmt.Errorf("%w: parsing scheduling overlay: %w", ErrUnreadable, err)
}
*target = doc.Scheduling
return nil
}