Skip to content
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

Validate settings before running Pulp instance #1671

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/1550.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Pulp Container specific settings are now properly validated during the deployment checks of a Pulp
instance.
1 change: 1 addition & 0 deletions pulp_container/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class PulpContainerPluginAppConfig(PulpPluginAppConfig):

def ready(self):
super().ready()
from . import checks
46 changes: 46 additions & 0 deletions pulp_container/app/checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django.conf import settings
from django.core.checks import Error as CheckError, register


@register(deploy=True)
def container_settings_check(app_configs, **kwargs):
errors = []

# Other checks only apply if token auth is enabled
if str(getattr(settings, "TOKEN_AUTH_DISABLED", False)).lower() == "true":
return errors

if getattr(settings, "TOKEN_SERVER", None) is None:
errors.append(
CheckError(
"TOKEN_SERVER is a required setting that has to be configured when token"
" authentification is enabled",
id="pulp_container.E001",
),
)
if getattr(settings, "TOKEN_SIGNATURE_ALGORITHM", None) is None:
errors.append(
CheckError(
"TOKEN_SIGNATURE_ALGORITHM is a required setting that has to be configured when"
" token authentification is enabled",
id="pulp_container.E001",
)
)
if getattr(settings, "PUBLIC_KEY_PATH", None) is None:
errors.append(
CheckError(
"PUBLIC_KEY_PATH is a required setting that has to be configured when token"
" authentification is enabled",
id="pulp_container.E001",
)
)
if getattr(settings, "PRIVATE_KEY_PATH", None) is None:
errors.append(
CheckError(
"PRIVATE_KEY_PATH is a required setting that has to be configured when token"
" authentification is enabled",
id="pulp_container.E001",
)
)

return errors
Loading