Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/service_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Configuration values are read from various sources using the following precedenc
- ``/etc/karton/karton.ini`` file (global)
- ``~/.config/karton/karton.ini`` file (user local)
- ``./karton.ini`` file (subsystem local)
- path provided via ``KARTON_CONFIG_FILE`` environment variable
- ``--config-path <path>`` optional, additional path provided in arguments
- ``KARTON_SECTION_OPTION`` values from environment variables e.g. (``secret_key`` option in ``[s3]`` section can be overridden using ``KARTON_S3_SECRET_KEY`` variable)
- Command-line arguments (if ``Karton.main()`` method is used as entrypoint)
Expand Down
7 changes: 7 additions & 0 deletions karton/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Config(object):
- ``/etc/karton/karton.ini`` (global)
- ``~/.config/karton/karton.ini`` (user local)
- ``./karton.ini`` (subsystem local)
- path from ``KARTON_CONFIG_FILE`` environment variable
- ``<path>`` optional, additional path provided in arguments

It is also possible to pass configuration via environment variables.
Expand All @@ -38,6 +39,12 @@ def __init__(
) -> None:
self._config: Dict[str, Dict[str, Any]] = {}

path_from_env = os.getenv("KARTON_CONFIG_FILE")
if path_from_env:
if not os.path.isfile(path_from_env):
raise IOError("Configuration file not found in " + path_from_env)
Comment thread
psrok1 marked this conversation as resolved.
Outdated
self.SEARCH_PATHS = self.SEARCH_PATHS + [path_from_env]

if path is not None:
if not os.path.isfile(path):
raise IOError("Configuration file not found in " + path)
Expand Down