-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate settings before running Pulp instance
When token authentization is enabled, 4 additional variables have to be set. The state of these variables is now checked, while properly informing the user, instead of relying on exceptions raised later during the instance's run. closes #1550
- Loading branch information
1 parent
e287091
commit 8973f80
Showing
3 changed files
with
49 additions
and
0 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
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. |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ class PulpContainerPluginAppConfig(PulpPluginAppConfig): | |
|
||
def ready(self): | ||
super().ready() | ||
from . import checks |
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 |
---|---|---|
@@ -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 |