-
-
Notifications
You must be signed in to change notification settings - Fork 0
Move env vars to config file #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1cf7504
read config / secrets from config file, not env
taylor-osler-sentry 30d969b
update ignores
taylor-osler-sentry abe6c0e
use dummy config for collectstatic and mypy, fix tests
taylor-osler-sentry 447c59b
add note to README
taylor-osler-sentry d757da7
Merge branch 'main' into config-file
spalmurray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Python-generated files | ||
| __pycache__/ | ||
| *.py[oc] | ||
| build/ | ||
| dist/ | ||
| wheels/ | ||
| *.egg-info | ||
|
|
||
| # Virtual environments | ||
| .venv | ||
|
|
||
| # Django | ||
| *.sqlite3 | ||
| config.toml | ||
|
|
||
| # Vite local .env files | ||
| .env | ||
| .env.* |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ wheels/ | |
|
|
||
| # Django | ||
| *.sqlite3 | ||
| config.toml | ||
|
|
||
| # Vite local .env files | ||
| .env | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| project_key = "INC" | ||
| django_secret_key = "django-insecure-gmj)qc*_dk&^i1=z7oy(ew7%5*fz^yowp8=4=0882_d=i3hl69" | ||
| sentry_dsn = "" | ||
|
|
||
| # This is the actual essential part. Values match the container set up by GHA | ||
| [postgres] | ||
| db = "firetower_test" | ||
| host = "localhost" | ||
| user = "postgres" | ||
| password = "postgres" | ||
|
|
||
| [jira] | ||
| domain = "" | ||
| account = "" | ||
| api_key = "" | ||
| severity_field = "" | ||
|
|
||
| [slack] | ||
| bot_token = "" | ||
| team_id = "" | ||
| participant_sync_throttle_seconds = 300 | ||
|
|
||
| [auth] | ||
| iap_enabled = false | ||
| iap_audience = "" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| project_key = "INC" | ||
| django_secret_key = "django-insecure-gmj)qc*_dk&^i1=z7oy(ew7%5*fz^yowp8=4=0882_d=i3hl69" | ||
| sentry_dsn = "https://your-sentry-dsn@o1.ingest.us.sentry.io/project-id" | ||
|
|
||
| [postgres] | ||
| db = "firetower" | ||
| host = "localhost" | ||
| user = "postgres" | ||
| password = "dummy_dev_password" | ||
|
|
||
| [jira] | ||
| domain = "https://<jira-domain>.atlassian.net" | ||
| account = "" | ||
| api_key = "" | ||
| severity_field = "customfield_11023" | ||
|
|
||
| [slack] | ||
| bot_token = "" | ||
| team_id = "<slack-team-id>" | ||
| participant_sync_throttle_seconds = 300 | ||
|
|
||
| [auth] | ||
| iap_enabled = false | ||
| iap_audience = "" | ||
|
|
||
| [datadog] | ||
| api_key = "" | ||
| app_key = "" |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| """ | ||
| Configuration file loader for Firetower. | ||
|
|
||
| Loads configuration values from a TOML file and validates that all required keys are present. | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| from serde import deserialize, from_dict | ||
| from serde.toml import from_toml | ||
|
|
||
|
|
||
| @deserialize | ||
| class PostgresConfig: | ||
| db: str | ||
| host: str | ||
| user: str | ||
| password: str | ||
|
|
||
|
|
||
| @deserialize | ||
| class DatadogConfig: | ||
| api_key: str | ||
| app_key: str | ||
|
|
||
|
|
||
| @deserialize | ||
| class JIRAConfig: | ||
| domain: str | ||
| account: str | ||
| api_key: str | ||
| severity_field: str | ||
|
|
||
|
|
||
| @deserialize | ||
| class SlackConfig: | ||
| bot_token: str | ||
| team_id: str | ||
| participant_sync_throttle_seconds: int | ||
|
|
||
|
|
||
| @deserialize | ||
| class AuthConfig: | ||
| iap_enabled: bool | ||
| iap_audience: str | None | ||
|
|
||
|
|
||
| @deserialize | ||
| class ConfigFile: | ||
| """ | ||
| Load string configuration values from a TOML file. | ||
| """ | ||
|
|
||
| postgres: PostgresConfig | ||
| datadog: DatadogConfig | None | ||
| jira: JIRAConfig | ||
| slack: SlackConfig | ||
| auth: AuthConfig | ||
|
|
||
| project_key: str | ||
| django_secret_key: str | ||
| sentry_dsn: str | ||
|
|
||
| @classmethod | ||
| def from_file(cls, file_path: str | Path) -> "ConfigFile": | ||
| """ | ||
| Load configuration from a TOML file. | ||
|
|
||
| Args: | ||
| file_path: Path to the TOML configuration file. | ||
|
|
||
| Returns: | ||
| ConfigFile instance with loaded configuration. | ||
| """ | ||
| with open(file_path) as f: | ||
| data: ConfigFile = from_toml(ConfigFile, f.read()) | ||
| return data | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data: dict[str, Any]) -> "ConfigFile": | ||
| """ | ||
| Load configuration from a dictionary. | ||
|
|
||
| Args: | ||
| data: Dictionary containing configuration key-value pairs. | ||
|
|
||
| Returns: | ||
| ConfigFile instance with loaded configuration. | ||
| """ | ||
| return from_dict(ConfigFile, data) | ||
|
|
||
|
|
||
| class DummyConfigFile(ConfigFile): | ||
| """ | ||
| A dummy configuration file for use when running collectstatic. | ||
| """ | ||
|
|
||
| def __init__(self) -> None: | ||
| self.postgres = PostgresConfig( | ||
| db="firetower", | ||
| host="localhost", | ||
| user="postgres", | ||
| password="dummy_dev_password", | ||
| ) | ||
| self.jira = JIRAConfig( | ||
| domain="", | ||
| account="", | ||
| api_key="", | ||
| severity_field="", | ||
| ) | ||
| self.slack = SlackConfig( | ||
| bot_token="", | ||
| team_id="", | ||
| participant_sync_throttle_seconds=0, | ||
| ) | ||
| self.auth = AuthConfig( | ||
| iap_enabled=False, | ||
| iap_audience="", | ||
| ) | ||
| self.datadog = None | ||
| self.project_key = "" | ||
| self.django_secret_key = "" | ||
| self.sentry_dsn = "" |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.