-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from grillazz/63-refactor-project-config
63 refactor project config
- Loading branch information
Showing
9 changed files
with
47 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,14 @@ jobs: | |
UP: up | ||
DOWN: down | ||
WEB_SERVER: web_server | ||
MONGO_HOST: mongodb | ||
MONGO_PORT: 27017 | ||
MONGO_USER: farmer | ||
MONGO_PASS: tractor | ||
MONGO_DB: greenhouse | ||
MONGO_COLLECTION: greens | ||
MONGO_TEST_DB: farmland | ||
MONGODB_HOST: mongodb | ||
MONGODB_PORT: 27017 | ||
MONGODB_USER: farmer | ||
MONGODB_PASSWORD: tractor | ||
MONGODB_DATABASE: greenhouse | ||
MONGODB_COLLECTION: greens | ||
MONGODB_TEST: farmland | ||
MONGODB_PARAMS: retryWrites=true&w=majority | ||
MONGO_URL: mongodb://farmer:[email protected]:27017/?retryWrites=true&w=majority | ||
|
||
services: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
import os | ||
|
||
from pydantic import MongoDsn, computed_field | ||
from pydantic_core import MultiHostUrl | ||
from pydantic_settings import BaseSettings | ||
|
||
|
||
class Settings(BaseSettings): | ||
""" | ||
Represents the configuration settings for the application. | ||
Args: | ||
environment (str): The environment in which the application is running. Defaults to "local". | ||
testing (str): The testing mode of the application. Defaults to "0". | ||
up (str): The up status of the application. Defaults to "up". | ||
down (str): The down status of the application. Defaults to "down". | ||
web_server (str): The web server used by the application. Defaults to "web_server". | ||
db_url (str): The URL of the MongoDB database. | ||
db_name (str): The name of the MongoDB database. | ||
collection (str): The name of the MongoDB collection. | ||
test_db_name (str): The name of the MongoDB test database. | ||
""" | ||
"""Settings for the application""" | ||
environment: str = os.getenv("ENVIRONMENT", "local") | ||
testing: str = os.getenv("TESTING", "0") | ||
up: str = os.getenv("UP", "up") | ||
down: str = os.getenv("DOWN", "down") | ||
web_server: str = os.getenv("WEB_SERVER", "web_server") | ||
|
||
db_url: str = os.getenv("MONGO_URL", "") | ||
db_name: str = os.getenv("MONGO_DB", "") | ||
collection: str = os.getenv("MONGO_COLLECTION", "") | ||
test_db_name: str = os.getenv("MONGO_TEST_DB", "") | ||
mongodb_database: str = os.getenv("MONGODB_DATABASE", "") | ||
mongodb_collection: str = os.getenv("MONGODB_COLLECTION", "") | ||
mongodb_test: str = os.getenv("MONGODB_TEST", "") | ||
|
||
MONGODB_HOST: str | ||
MONGODB_PORT: int | ||
MONGODB_USER: str | ||
MONGODB_PASSWORD: str | ||
MONGODB_PARAMS: str | ||
|
||
@computed_field | ||
@property | ||
def mongodb_url(self) -> MongoDsn: | ||
return MultiHostUrl.build( | ||
scheme="mongodb", | ||
host=self.MONGODB_HOST, | ||
port=self.MONGODB_PORT, | ||
username=self.MONGODB_USER, | ||
password=self.MONGODB_PASSWORD, | ||
|
||
path=self.MONGODB_PARAMS | ||
) | ||
|
||
|
||
settings = Settings() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters