You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Adding DEV, PROD, TEST environment variables #247
I would like to be able to change the code of my application using env variables, eg change the port based on which mode the FOCA app is running or change the configuration etc. This might seem like a per project level requirement, but having this defined either in config.yaml with strict typing to standardize the variable name might be helpful.
Do you want to have bifurcation on the basis of different config files or a single config file? While I understand the need to such particulars, we might need to think on adding such support from a more holistic perspective as to have a long term solution based on scope and requirements. I like the idea of have a dedicated config for prod staging etc, but do we want to think in some additional directions as well? As to have a boiler plate based on different config files or to move such variables and abstract them out? Any additional thoughts?
Decision: no environments: section and no built-in mode enum. Instead, FOCA will accept several config files that are deep-merged in order, and an environment variable selects overlays at deploy time:
Foca(config_file=...) accepts a path or a sequence of paths. Files are merged left to right before validation: mappings are merged recursively; lists and scalars from later files replace earlier ones; null sets a value to null.
Environment variable FOCA_CONFIG_OVERLAY: one or more paths, separated by os.pathsep (: on Linux), appended after the files passed in code. Relative paths are resolved against the current working directory, like other CLI/env paths.
Typical setup: config.yaml (base, committed) plus config.dev.yaml/config.prod.yaml; e.g. FOCA_CONFIG_OVERLAY=deployment/config.prod.yaml. In Kubernetes, the overlay can come from a ConfigMap.
Validation runs once on the merged result; the files used are logged at INFO.
Apps that need a "mode" in their own code put it in custom and set it in the overlay.
Activity
kushagra189 commentedon Dec 20, 2024
Do you want to have bifurcation on the basis of different config files or a single config file? While I understand the need to such particulars, we might need to think on adding such support from a more holistic perspective as to have a long term solution based on scope and requirements. I like the idea of have a dedicated config for prod staging etc, but do we want to think in some additional directions as well? As to have a boiler plate based on different config files or to move such variables and abstract them out? Any additional thoughts?
uniqueg commentedon Oct 18, 2026
Refined proposal
Decision: no
environments:section and no built-in mode enum. Instead, FOCA will accept several config files that are deep-merged in order, and an environment variable selects overlays at deploy time:Foca(config_file=...)accepts a path or a sequence of paths. Files are merged left to right before validation: mappings are merged recursively; lists and scalars from later files replace earlier ones;nullsets a value tonull.FOCA_CONFIG_OVERLAY: one or more paths, separated byos.pathsep(:on Linux), appended after the files passed in code. Relative paths are resolved against the current working directory, like other CLI/env paths.config.yaml(base, committed) plusconfig.dev.yaml/config.prod.yaml; e.g.FOCA_CONFIG_OVERLAY=deployment/config.prod.yaml. In Kubernetes, the overlay can come from a ConfigMap.customand set it in the overlay.Acceptance criteria
Foca/ConfigParseraccept multiple files; merge semantics unit-tested (nested dict, list replacement,null).FOCA_CONFIG_OVERLAYwith one and with two paths, and a missing overlay file (clear error), tested.Breaking changes
None (additive).
ConfigParser.merge_yamlis reused for config files and may be renamed.Planned PR
9 (
feat(config): config overlays, relative paths), together with #209.