Improve config handling, add API-based config update - #554
Merged
Conversation
Contributor
Author
Contributor
Author
|
Note: this PR also fixes a small unrelated bug where |
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
This moves config generation and drift-detection out of the docker
entrypoint.shso both docker and bare metal can use it. Adds an API optionPOST /config/sync(gated behindAPI_ALLOW_CONFIG_WRITE) to update the config if new features are added, which keeps a user's existing config and adds the new keys with their defaults. Bare metal config loading (Load.ts/Validator.ts) is untouched.Auto-update for the config can also be set with
CONFIG_AUTO_SYNC=true, and is off (false) by default. Missing keys are written intoconfig.jsonwith their example defaults on every start (a.bakbackup is kept). Existing values are never overwritten either way.Changes
src/util/ConfigSync.ts(new) — single source of truth for generatingconfig.jsonfrom the example and detecting/patching missing keys. Replaces duplicate diff/generation logic that previously lived in both bash and the API.src/util/ConfigEnvOverrides.ts(new) — single source of truth for theCONFIG_*env var → config path mapping. Replaces the duplicate list that previously lived as both anentrypoint.shcomment block and its_cfg/_cfg_arraycalls.entrypoint.sh(edited) — config generation, drift-checking, and env-override application now delegate to the two modules above, replacing ~275 lines of bash/jq.scripts/api/configEditor.js(edited) — addeddiffConfig/syncMissingDefaults, thin wrappers aroundConfigSync.ts, for use by the Control API.scripts/api/server.js(edited) — addedGET /config/diffandPOST /config/syncroutes exposing the above over HTTP.Note:
node dist/util/ConfigEnvOverrides.js listprints every supportedCONFIG_*env var, the config path it maps to, and its type, useful as a live reference instead of the old hand-maintained comment block