Skip to content

Commit

Permalink
feat: read configuration from environment vars and custom dotenv file
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Apr 22, 2024
1 parent 360405d commit c5b0ee8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

## Changed

- Configuration is read from `.pytest-iam.env`
- Configuration is read from enviroment vars prefixed by `PYTEST_IAM_`

## [0.0.11] - 2024-04-22

### Changed
Expand Down
5 changes: 5 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ This returns a :const:`dict` containing the canaille :doc:`canaille:configuratio
def iam_configuration(iam_configuration):
iam_configuration["ACL"]["DEFAULT"]["WRITE"].append("groups")
return iam_configuration
The configuration will also be read:

- from a `.pytest-iam.env` file if existing;
- from any environment var with a valid Canaille setting name prefixed by `PYTEST_IAM_`.
4 changes: 3 additions & 1 deletion pytest_iam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def iam_server(iam_configuration) -> Server:
thread."""

port = portpicker.pick_unused_port()
app = create_app(config=iam_configuration)
app = create_app(
config=iam_configuration, env_file=".pytest-iam.env", env_prefix="PYTEST_IAM_"
)
server = Server(app, port)

server_thread = threading.Thread(target=server.httpd.serve_forever)
Expand Down

0 comments on commit c5b0ee8

Please sign in to comment.