Skip to content

Commit

Permalink
All app config is snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
fajpunk committed Nov 11, 2024
1 parent c4e7fd5 commit 01cc4fc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 45 deletions.
8 changes: 4 additions & 4 deletions docs/development/idfdev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tab> 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
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions docs/operations/github_ci_app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions docs/operations/github_refresh_app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
24 changes: 7 additions & 17 deletions src/mobu/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
...,
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions tests/data/config/autostart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/data/config/base.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions tests/data/config/github_ci_app.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/data/config/github_refresh_app.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 01cc4fc

Please sign in to comment.