mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Make up default values for tower configurations
This commit is contained in:
parent
36f49467c6
commit
e8bd477f1e
@ -11,7 +11,7 @@ from django.http import Http404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# Django REST Framework
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
from rest_framework.exceptions import PermissionDenied, ValidationError
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import serializers
|
||||
from rest_framework import status
|
||||
@ -180,6 +180,13 @@ class SettingLoggingTest(GenericAPIView):
|
||||
obj = type('Settings', (object,), defaults)()
|
||||
serializer = self.get_serializer(obj, data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
# Special validation specific to logging test.
|
||||
errors = {}
|
||||
for key in ['LOG_AGGREGATOR_TYPE', 'LOG_AGGREGATOR_HOST']:
|
||||
if not request.data.get(key, ''):
|
||||
errors[key] = 'This field is required.'
|
||||
if errors:
|
||||
raise ValidationError(errors)
|
||||
|
||||
if request.data.get('LOG_AGGREGATOR_PASSWORD', '').startswith('$encrypted$'):
|
||||
serializer.validated_data['LOG_AGGREGATOR_PASSWORD'] = getattr(
|
||||
|
||||
@ -329,6 +329,7 @@ register(
|
||||
'LOG_AGGREGATOR_HOST',
|
||||
field_class=fields.CharField,
|
||||
allow_null=True,
|
||||
default=None,
|
||||
label=_('Logging Aggregator'),
|
||||
help_text=_('Hostname/IP where external logs will be sent to.'),
|
||||
category=_('Logging'),
|
||||
@ -338,6 +339,7 @@ register(
|
||||
'LOG_AGGREGATOR_PORT',
|
||||
field_class=fields.IntegerField,
|
||||
allow_null=True,
|
||||
default=None,
|
||||
label=_('Logging Aggregator Port'),
|
||||
help_text=_('Port on Logging Aggregator to send logs to (if required and not'
|
||||
' provided in Logging Aggregator).'),
|
||||
@ -350,6 +352,7 @@ register(
|
||||
field_class=fields.ChoiceField,
|
||||
choices=['logstash', 'splunk', 'loggly', 'sumologic', 'other'],
|
||||
allow_null=True,
|
||||
default=None,
|
||||
label=_('Logging Aggregator Type'),
|
||||
help_text=_('Format messages for the chosen log aggregator.'),
|
||||
category=_('Logging'),
|
||||
|
||||
@ -535,6 +535,7 @@ register(
|
||||
'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('Google OAuth2 Key'),
|
||||
help_text=_('The OAuth2 key from your web application at https://console.developers.google.com/.'),
|
||||
category=_('Google OAuth2'),
|
||||
@ -546,6 +547,7 @@ register(
|
||||
'SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('Google OAuth2 Secret'),
|
||||
help_text=_('The OAuth2 secret from your web application at https://console.developers.google.com/.'),
|
||||
category=_('Google OAuth2'),
|
||||
@ -627,6 +629,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_KEY',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub OAuth2 Key'),
|
||||
help_text=_('The OAuth2 key (Client ID) from your GitHub developer application.'),
|
||||
category=_('GitHub OAuth2'),
|
||||
@ -637,6 +640,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_SECRET',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub OAuth2 Secret'),
|
||||
help_text=_('The OAuth2 secret (Client Secret) from your GitHub developer application.'),
|
||||
category=_('GitHub OAuth2'),
|
||||
@ -691,6 +695,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_ORG_KEY',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Organization OAuth2 Key'),
|
||||
help_text=_('The OAuth2 key (Client ID) from your GitHub organization application.'),
|
||||
category=_('GitHub Organization OAuth2'),
|
||||
@ -701,6 +706,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_ORG_SECRET',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Organization OAuth2 Secret'),
|
||||
help_text=_('The OAuth2 secret (Client Secret) from your GitHub organization application.'),
|
||||
category=_('GitHub Organization OAuth2'),
|
||||
@ -712,6 +718,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_ORG_NAME',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Organization Name'),
|
||||
help_text=_('The name of your GitHub organization, as used in your '
|
||||
'organization\'s URL: https://github.com/<yourorg>/.'),
|
||||
@ -766,6 +773,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_TEAM_KEY',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Team OAuth2 Key'),
|
||||
help_text=_('The OAuth2 key (Client ID) from your GitHub organization application.'),
|
||||
category=_('GitHub Team OAuth2'),
|
||||
@ -776,6 +784,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_TEAM_SECRET',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Team OAuth2 Secret'),
|
||||
help_text=_('The OAuth2 secret (Client Secret) from your GitHub organization application.'),
|
||||
category=_('GitHub Team OAuth2'),
|
||||
@ -787,6 +796,7 @@ register(
|
||||
'SOCIAL_AUTH_GITHUB_TEAM_ID',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('GitHub Team ID'),
|
||||
help_text=_('Find the numeric team ID using the Github API: '
|
||||
'http://fabian-kostadinov.github.io/2015/01/16/how-to-find-a-github-team-id/.'),
|
||||
@ -841,6 +851,7 @@ register(
|
||||
'SOCIAL_AUTH_AZUREAD_OAUTH2_KEY',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('Azure AD OAuth2 Key'),
|
||||
help_text=_('The OAuth2 key (Client ID) from your Azure AD application.'),
|
||||
category=_('Azure AD OAuth2'),
|
||||
@ -851,6 +862,7 @@ register(
|
||||
'SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET',
|
||||
field_class=fields.CharField,
|
||||
allow_blank=True,
|
||||
default='',
|
||||
label=_('Azure AD OAuth2 Secret'),
|
||||
help_text=_('The OAuth2 secret (Client Secret) from your Azure AD application.'),
|
||||
category=_('Azure AD OAuth2'),
|
||||
|
||||
@ -84,6 +84,8 @@ Here is the details of each argument:
|
||||
|
||||
During Tower bootstrapping, All settings registered in `conf.py` modules of Tower Django apps will be loaded (registered). The set of Tower configuration settings will form a new top-level of `django.conf.settings` object. Later all Tower configuration settings will be available as attributes of it, just like normal Django settings. Note Tower configuration settings take higher priority over normal settings, meaning if a setting `FOOBAR` is both defined in a settings file and registered in a `conf.py`, the registered attribute will be used over the defined attribute every time.
|
||||
|
||||
Note when registering new configurations, it is desired to provide a default value if it is possible to do so, as Tower configuration UI has a 'revert all' functionality that revert all settings to it's default value.
|
||||
|
||||
Starting from 3.2, Tower configuration supports category-specific validation functions. They should also be defined under `conf.py` in the form
|
||||
```python
|
||||
def custom_validate(serializer, attrs):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user