Mohammed Naser | d531f36 | 2022-09-16 11:38:55 -0400 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | |
| 4 | import confspirator |
| 5 | from confspirator import groups |
| 6 | |
| 7 | from atmosphere.config import images, memcached |
| 8 | |
| 9 | _root_config = groups.ConfigGroup("atmosphere") |
| 10 | _root_config.register_child_config(images.config_group) |
| 11 | _root_config.register_child_config(memcached.config_group) |
| 12 | |
Mohammed Naser | 34b8a39 | 2022-09-16 16:39:58 -0400 | [diff] [blame] | 13 | CONFIG_FILE = os.environ.get("ATMOSPHERE_CONFIG", "/etc/atmosphere/config.toml") |
Mohammed Naser | d531f36 | 2022-09-16 11:38:55 -0400 | [diff] [blame] | 14 | |
| 15 | |
Mohammed Naser | f9cb89b | 2022-09-18 10:42:37 -0400 | [diff] [blame^] | 16 | def load_config(file=CONFIG_FILE): |
Mohammed Naser | d531f36 | 2022-09-16 11:38:55 -0400 | [diff] [blame] | 17 | if "pytest" in sys.modules: |
| 18 | return confspirator.load_dict(_root_config, {}, test_mode=True) |
| 19 | |
Mohammed Naser | f9cb89b | 2022-09-18 10:42:37 -0400 | [diff] [blame^] | 20 | return confspirator.load_file(_root_config, file) |
Mohammed Naser | d531f36 | 2022-09-16 11:38:55 -0400 | [diff] [blame] | 21 | |
| 22 | |
Mohammed Naser | f9cb89b | 2022-09-18 10:42:37 -0400 | [diff] [blame^] | 23 | CONF = load_config() |