Skip to content

Support dynamic settings sections - #1

Closed
teal-bauer wants to merge 3 commits into
mainfrom
dynamic-settings-sections
Closed

Support dynamic settings sections#1
teal-bauer wants to merge 3 commits into
mainfrom
dynamic-settings-sections

Conversation

@teal-bauer

@teal-bauer teal-bauer commented Oct 26, 2025

Copy link
Copy Markdown
Member

Summary

Adding engine-ecu to the service meant touching Config, ParseRedisSettings, and ToRedisFields — all for a struct field and a HasPrefix check. Any section.key key already carries its section name; there's no reason to maintain an allowlist.

  • Replace hardcoded Config fields with map[string]map[string]interface{}
  • ParseRedisSettings splits on first dot, creates sections dynamically
  • ToRedisFields iterates all sections generically
  • Keys without a dot are silently dropped

Existing settings (scooter.*, cellular.*, etc.) work as before. New sections don't require code changes. Includes unit tests for standard sections, arbitrary names, dotless keys, and round-trips.

@teal-bauer
teal-bauer force-pushed the dynamic-settings-sections branch from 8fc973e to 609fa3c Compare March 9, 2026 08:47
Remove hardcoded section prefixes and allow any dotted-notation
keys in the settings hash. All keys with format "section.key" are
automatically parsed and organized into TOML sections.

Keys without dots are silently ignored to maintain backward
compatibility and ensure proper structure.
Add comprehensive tests for ParseRedisSettings and ToRedisFields:
- Standard and custom section parsing
- Ignoring keys without dots
- Handling keys with multiple dots
- Round-trip conversion validation
@teal-bauer
teal-bauer force-pushed the dynamic-settings-sections branch from 609fa3c to 1a6068d Compare March 12, 2026 11:13
Keys without a dot are stored as top-level TOML entries rather than
silently dropped. TOML loading splits by value type (map vs scalar) to
distinguish sections from top-level fields.

Service layer warns on unknown sections and top-level keys in both
directions (TOML→Redis and Redis→TOML).
@teal-bauer

Copy link
Copy Markdown
Member Author

Empty sections ([cellular], [engine-ecu]) in the existing settings.toml are lost after a Redis round-trip — the old hardcoded struct wrote them unconditionally; the dynamic approach only writes sections that have keys. Shouldn't matter in practice since nothing reads the TOML directly, but worth knowing.

@teal-bauer
teal-bauer requested a review from Zanooda March 12, 2026 12:03
@teal-bauer

Copy link
Copy Markdown
Member Author

Superseded by #4, which drops the Config struct entirely for map[string]map[string]interface{} and moves the unknown-section warning to schema.Has() so the allowlist is schema-driven. #3 then emits nested TOML sub-tables for dotted keys. Closing in favor of those; will port the round-trip tests separately.

@teal-bauer teal-bauer closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant