Skip to content

Commit c5b0ee8

Browse files
committed
feat: read configuration from environment vars and custom dotenv file
1 parent 360405d commit c5b0ee8

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
Versions follow [Semantic Versioning](https://semver.org/>) (<major>.<minor>.<patch>).
99

10+
## Changed
11+
12+
- Configuration is read from `.pytest-iam.env`
13+
- Configuration is read from enviroment vars prefixed by `PYTEST_IAM_`
14+
1015
## [0.0.11] - 2024-04-22
1116

1217
### Changed

doc/configuration.rst

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ This returns a :const:`dict` containing the canaille :doc:`canaille:configuratio
1010
def iam_configuration(iam_configuration):
1111
iam_configuration["ACL"]["DEFAULT"]["WRITE"].append("groups")
1212
return iam_configuration
13+
14+
The configuration will also be read:
15+
16+
- from a `.pytest-iam.env` file if existing;
17+
- from any environment var with a valid Canaille setting name prefixed by `PYTEST_IAM_`.

pytest_iam/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ def iam_server(iam_configuration) -> Server:
184184
thread."""
185185

186186
port = portpicker.pick_unused_port()
187-
app = create_app(config=iam_configuration)
187+
app = create_app(
188+
config=iam_configuration, env_file=".pytest-iam.env", env_prefix="PYTEST_IAM_"
189+
)
188190
server = Server(app, port)
189191

190192
server_thread = threading.Thread(target=server.httpd.serve_forever)

0 commit comments

Comments
 (0)