feat(settings): seed settings from OPENC3_SETTING_* env vars - #3699
Draft
mcosgriff wants to merge 12 commits into
Draft
feat(settings): seed settings from OPENC3_SETTING_* env vars#3699mcosgriff wants to merge 12 commits into
mcosgriff wants to merge 12 commits into
Conversation
- Add `openc3cli initsettings`, run by init.sh, which seeds settings from OPENC3_SETTING_<NAME> variables so time zone, time format and other Admin Console values can be configured at deploy time - Only write a setting that doesn't already exist so Admin Console edits survive a restart; OPENC3_SETTINGS_OVERWRITE makes the environment authoritative - Reject an unrecognized setting name (suggesting the near match) rather than writing a dead Redis key a typo would leave behind; OPENC3_SETTINGS_ALLOW_UNKNOWN opts out for settings added by a newer tool - Coerce values as JSON so boolean settings like ai_chat aren't stored as the string "false", which is truthy in the frontend - Add ConfigParser.handle_true_false_strict, which accepts 1/TRUE/0/FALSE and raises otherwise, so OPENC3_SETTINGS_OVERWRITE=0 means off rather than the on implied by the OPENC3_NO_* presence flags - Apply the same seed guard and JSON coercion to LocalMode.sync_settings, which previously overwrote Redis on every localinit and stored files verbatim - Document the variables in compose.override.yaml; compose.yaml is unchanged because an override's environment block adds variables it doesn't list
…o-overwrite-settings-in-init
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3699 +/- ##
==========================================
+ Coverage 79.30% 79.35% +0.05%
==========================================
Files 885 885
Lines 65367 65494 +127
Branches 2585 2585
==========================================
+ Hits 51839 51975 +136
+ Misses 12857 12847 -10
- Partials 671 672 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Coerce each value by its setting's declared type rather than by attempting JSON.parse: booleans reach Redis as real booleans (the string "false" is truthy in the frontend) while every other setting keeps the text given - Fix astro, classification_banner and context_tag being stored as parsed objects. Those components JSON.parse the stored value, so a Hash makes them throw. Type-driven coercion also stops a subtitle of "2024" becoming the number 2024 - Enumerate all 14 Admin Console settings in KNOWN_SETTINGS with their types and allowed values. The table previously held 4, so OPENC3_SETTING_THEME failed as an unknown name - Add SettingModel.describe_settings, used by `cli initsettings --help`, so the documented list is generated from the table and can't drift - Document how to add a setting above KNOWN_SETTINGS, including how to tell a JSON-text setting from an object one - Point compose.override.yaml at `cli initsettings --help` instead of repeating the list, and show the boolean, free text and JSON text forms
- Add .claude/commands/commit-message.md following Conventional Commits v1.0.0, citing the numbered rules and separating them from git convention like the 72 character first line, so the same file works in any repo - Scope the command to git diff --cached only, so committed-but-unpushed work, unstaged changes and untracked files stay out of the generated message - Point CLAUDE.md at the command instead of restating the format, dropping the duplicated Angular rules and the 2-4 line body cap that contradicted it - Remove the 🤖 Generated with Claude Code footer, which is not a valid token: value footer under rule 9 - Delete generate-commit-message.md, fully superseded by the new command
- Compare KNOWN_SETTINGS against the setting names and types extracted from the Vue components so the table cannot silently fall behind. The previous "seeds every setting" test looped over the table itself, so dropping a row kept it green - Assert the declared type matches what each component passes to saveSetting, catching a JSON text setting declared as a boolean. Both directions verified by mutation - Require the heuristics to resolve every setting rather than only agreeing on what they resolved, so a component shape infer_type does not handle fails instead of quietly shrinking the check - Fix tool_config_model_spec "deletes", which depended on ambient container state: delete_tool_config returns nil early unless OPENC3_LOCAL_MODE is set and the local mode path exists, so the test only passed in Docker. Set both up against a temp dir and restore them after - Assert the config file is actually removed, not just that rm_f echoed the path it was asked to remove, and cover the early-return branch with local mode off
- Wrap body lines at 72 characters, cap the body at 5 bullets, and allow one sentence each so git log stays readable - Drop the "note a non-obvious consequence" guidance, which invited a second sentence on nearly every bullet
- Read OPENC3_LOCAL_MODE via ENV.fetch with an explicit nil default, since nil records that the variable was unset - Add else clauses to the two case statements in setting_model_spec, making the existing implicit nil fall-through explicit
- Add initsettings to the cli command list and to the branch offering only --help, since it takes no positional arguments - Add reingest, which was missing entirely, with its own branch prompting JOB_ID then SCOPE as both are required
- Indent every commented service block so uncommenting yields valid YAML, since a service at column 0 fails with "additional properties 'openc3-cosmos-init' not allowed" - Document that services: must be uncommented too, quoting that error so the message maps to the cause - Stop the log to stderr section redeclaring openc3-operator, which collided with the block above and discarded its ports and volumes
- Record each value initsettings writes to a companion Redis hash, so a later init can tell an untouched setting from one an operator changed - Apply a changed env value while the setting still matches what was seeded, which makes editing the override and restarting work - Leave any setting whose value differs from the seeded one, including settings with no record from before this tracking existed - Name the destroyed value when OPENC3_SETTINGS_OVERWRITE clobbers an edit, which previously logged the same line as a first-time seed
- Add --dry-run, which reports the action planned for each setting, writes nothing, and exits non-zero if any would fail - Skip an invalid setting instead of aborting init, which crash looped COSMOS under restart: on-failure over a cosmetic value - Run cli initsettings in the init container, the only one that receives OPENC3_SETTING_* variables - Extract plan_setting so a dry run cannot report one thing and the real run do another - Fall back to name and value checks when Redis is unreachable, so the check is usable before starting COSMOS
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Closes #3471. Customers can configure default time zone and time format (and any other Admin Console setting) at deploy time instead of clicking through the Admin Console after every fresh install.
openc3cli initsettings, run byinit.shafterinitbuckets, which seeds settings fromOPENC3_SETTING_<NAME>environment variables. A prefix scan rather than an enumerated list, so a setting added by a later release needs no code change here.OPENC3_SETTINGS_OVERWRITEmakes the environment authoritative instead.OPENC3_SETTING_TIME_ZONESwould otherwise be a dead Redis key plus a setting the operator believes they configured and did not.OPENC3_SETTINGS_ALLOW_UNKNOWNopts out for a setting a newer tool added.ConfigParser.handle_true_false_strict, accepting1/TRUE/0/FALSEand raising otherwise.handle_true_falseitself is unchanged because table_config.rb:268 feeds item defaults through it, where mapping'1'totruewould corrupt a numeric default of 1. This makesOPENC3_SETTINGS_OVERWRITE=0mean off, unlike theOPENC3_NO_*presence flags where=0counts as on.LocalMode.sync_settings, which overwrote Redis on everylocalinit(reverting Admin Console edits) and stored file contents verbatim (so a boolean setting round-tripped to a truthy string). It now uses the same seed guard and JSON coercion.compose.override.yaml.compose.yamlis deliberately unchanged: an override'senvironment:block adds variables the base file does not list, so no compose.yaml edit is ever needed to add a setting.cli initsettings --helpso the list can't drift from the codeExample:
Test plan