From 01cc4fcb7c30da190fddddc217e2415d84d51355 Mon Sep 17 00:00:00 2001 From: Dan Fuchs Date: Mon, 11 Nov 2024 16:53:04 -0600 Subject: [PATCH] All app config is snake_case --- docs/development/idfdev.rst | 8 ++++---- docs/operations/github_ci_app.rst | 8 ++++---- docs/operations/github_refresh_app.rst | 8 ++++---- src/mobu/config.py | 24 +++++++---------------- tests/data/config/autostart.yaml | 6 +++--- tests/data/config/base.yaml | 6 +++--- tests/data/config/github_ci_app.yaml | 10 +++++----- tests/data/config/github_refresh_app.yaml | 10 +++++----- 8 files changed, 35 insertions(+), 45 deletions(-) diff --git a/docs/development/idfdev.rst b/docs/development/idfdev.rst index c5a85bb9..c092e001 100644 --- a/docs/development/idfdev.rst +++ b/docs/development/idfdev.rst @@ -25,10 +25,10 @@ You can run mobu locally while having all of the actual business run against ser # Note: This whitespace must be actual chars! cat <<-'END' >"$config_path" logLevel: debug - githubRefreshApp: - acceptedGithubOrgs: + github_refresh_app: + accepted_github_orgs: - lsst-sqre - githubCiApp: + github_ci_app: users: - username: bot-mobu-ci-local-1 - username: bot-mobu-ci-local-2 @@ -37,7 +37,7 @@ You can run mobu locally while having all of the actual business run against ser - "exec:portal" - "read:image" - "read:tap" - acceptedGithubOrgs: + accepted_github_orgs: - lsst-sqre autostart: - name: "my-test" diff --git a/docs/operations/github_ci_app.rst b/docs/operations/github_ci_app.rst index 27d02549..692b070e 100644 --- a/docs/operations/github_ci_app.rst +++ b/docs/operations/github_ci_app.rst @@ -35,13 +35,13 @@ Install the app for a repo Add Phalanx configuration ========================= -In :samp:`applications/mobu/values-{env}.yaml`, add a ``config.githubCiApp`` value: +In :samp:`applications/mobu/values-{env}.yaml`, add a ``config.github_ci_app`` value: .. code:: yaml config: - githubCiApp: - acceptedGithubOrgs: + github_ci_app: + accepted_github_orgs: - lsst-sqre users: - username: "bot-mobu-ci-user-1" @@ -58,7 +58,7 @@ In :samp:`applications/mobu/values-{env}.yaml`, add a ``config.githubCiApp`` val All items are required. -``acceptedGithubOrgs`` +``accepted_github_orgs`` A list of GitHub organizations from which this instance of Mobu will accept webhook requests. Webhook requests from any orgs not in this list will get a ``403`` response. diff --git a/docs/operations/github_refresh_app.rst b/docs/operations/github_refresh_app.rst index 34694308..14382ff4 100644 --- a/docs/operations/github_refresh_app.rst +++ b/docs/operations/github_refresh_app.rst @@ -32,17 +32,17 @@ Install the app for a repo Add Phalanx configuration ========================= -In :samp:`applications/mobu/values-{env}.yaml`, add a ``config.githubRefreshApp`` value: +In :samp:`applications/mobu/values-{env}.yaml`, add a ``config.github_refresh_app`` value: .. code:: yaml config: - githubRefreshApp: - acceptedGithubOrgs: + github_refresh_app: + accepted_github_orgs: - lsst-sqre All of these items are required. -``acceptedGithubOrgs`` +``accepted_github_orgs`` A list of GitHub organizations from which this instance of Mobu will accept webhook requests. Webhook requests from any orgs not in this list will get a ``403`` response. diff --git a/src/mobu/config.py b/src/mobu/config.py index 86cd50bc..00707eff 100644 --- a/src/mobu/config.py +++ b/src/mobu/config.py @@ -26,9 +26,7 @@ class GitHubCiAppConfig(BaseSettings): """Configuration for GitHub CI app functionality if it is enabled.""" - model_config = SettingsConfigDict( - alias_generator=to_camel, extra="forbid", populate_by_name=True - ) + model_config = SettingsConfigDict(extra="forbid") id: int = Field( ..., @@ -39,7 +37,7 @@ class GitHubCiAppConfig(BaseSettings): " https://github.com/organizations/lsst-sqre/settings/apps/mobu-ci-data-dev-lsst-cloud" ), examples=[123456], - validation_alias=AliasChoices("MOBU_GITHUB_CI_APP_ID", "id"), + validation_alias="MOBU_GITHUB_CI_APP_ID", ) private_key: str = Field( @@ -60,9 +58,7 @@ class GitHubCiAppConfig(BaseSettings): -----END RSA PRIVATE KEY----- """) ], - validation_alias=AliasChoices( - "MOBU_GITHUB_CI_APP_PRIVATE_KEY", "privateKey" - ), + validation_alias="MOBU_GITHUB_CI_APP_PRIVATE_KEY", ) webhook_secret: str = Field( @@ -72,9 +68,7 @@ class GitHubCiAppConfig(BaseSettings): "Generated when the GitHub app was set up. You can find this" " in 1Password; check the Phalanx mobu values for more details." ), - validation_alias=AliasChoices( - "MOBU_GITHUB_CI_APP_WEBHOOK_SECRET", "webhookSecret" - ), + validation_alias="MOBU_GITHUB_CI_APP_WEBHOOK_SECRET", ) users: list[User] = Field( @@ -124,9 +118,7 @@ class GitHubRefreshAppConfig(BaseSettings): "Generated when the GitHub app was set up. You can find this" " in 1Password; check the Phalanx mobu values for more details." ), - validation_alias=AliasChoices( - "MOBU_GITHUB_REFRESH_APP_WEBHOOK_SECRET", "webhookSecret" - ), + validation_alias="MOBU_GITHUB_REFRESH_APP_WEBHOOK_SECRET", ) accepted_github_orgs: list[str] = Field( @@ -163,7 +155,7 @@ class Configuration(BaseSettings): " set to `None`, this feature will be disabled." ), examples=["https://slack.example.com/ADFAW1452DAF41/"], - validation_alias=AliasChoices("MOBU_ALERT_HOOK", "alertHook"), + validation_alias="MOBU_ALERT_HOOK", ) environment_url: HttpUrl | None = Field( @@ -176,9 +168,7 @@ class Configuration(BaseSettings): " during startup." ), examples=["https://data.example.org/"], - validation_alias=AliasChoices( - "MOBU_ENVIRONMENT_URL", "environmentUrl" - ), + validation_alias="MOBU_ENVIRONMENT_URL", ) gafaelfawr_token: str | None = Field( diff --git a/tests/data/config/autostart.yaml b/tests/data/config/autostart.yaml index d8ed8f6e..93ac9190 100644 --- a/tests/data/config/autostart.yaml +++ b/tests/data/config/autostart.yaml @@ -1,6 +1,6 @@ -slackAlerts: true -environmentUrl: "https://example.com" -availableServices: +slack_alerts: true +environment_url: "https://example.com" +available_services: - some_service - some_other_service autostart: diff --git a/tests/data/config/base.yaml b/tests/data/config/base.yaml index 9f4a5101..c6363133 100644 --- a/tests/data/config/base.yaml +++ b/tests/data/config/base.yaml @@ -1,5 +1,5 @@ -slackAlerts: true -environmentUrl: "https://example.com" -availableServices: +slack_alerts: true +environment_url: "https://example.com" +available_services: - some_service - some_other_service diff --git a/tests/data/config/github_ci_app.yaml b/tests/data/config/github_ci_app.yaml index 33f86a86..a9cd1593 100644 --- a/tests/data/config/github_ci_app.yaml +++ b/tests/data/config/github_ci_app.yaml @@ -1,13 +1,13 @@ -slackAlerts: true -environmentUrl: "https://example.com" -availableServices: +slack_alerts: true +environment_url: "https://example.com" +available_services: - some_service - some_other_service -githubCiApp: +github_ci_app: users: - username: bot-mobu-unittest-1 - username: bot-mobu-unittest-2 - acceptedGithubOrgs: + accepted_github_orgs: - org1 - org2 - lsst-sqre diff --git a/tests/data/config/github_refresh_app.yaml b/tests/data/config/github_refresh_app.yaml index 12dab819..4d9b04ae 100644 --- a/tests/data/config/github_refresh_app.yaml +++ b/tests/data/config/github_refresh_app.yaml @@ -1,10 +1,10 @@ -slackAlerts: true -environmentUrl: "https://example.com" -availableServices: +slack_alerts: true +environment_url: "https://example.com" +available_services: - some_service - some_other_service -githubRefreshApp: - acceptedGithubOrgs: +github_refresh_app: + accepted_github_orgs: - org1 - org2 - lsst-sqre