mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Rename settings to be more generic, not GitHub-only
This commit is contained in:
@ -157,17 +157,17 @@ Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce uni
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## GITHUB_REPOSITORY_API
|
## UPDATE_REPO_URL
|
||||||
|
|
||||||
Default: 'https://api.github.com/repos/netbox-community/netbox'
|
Default: 'https://api.github.com/repos/netbox-community/netbox'
|
||||||
|
|
||||||
The releases of this repository are checked to detect new releases, which are shown on the home page of the web interface. You can change this to your own fork of the NetBox repository, or set it to `None` to disable the check.
|
The releases of this repository are checked to detect new releases, which are shown on the home page of the web interface. You can change this to your own fork of the NetBox repository, or set it to `None` to disable the check. The URL provided **must** be compatible with the GitHub API.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## GITHUB_CACHE_TIMEOUT
|
## UPDATE_CACHE_TIMEOUT
|
||||||
|
|
||||||
Default: 24 * 3600
|
Default: 86,400 (24 hours)
|
||||||
|
|
||||||
The number of seconds to retain the latest version that is fetched from the GitHub API before automatically invalidating it and fetching it from the API again. This must be set to at least one hour (3600 seconds).
|
The number of seconds to retain the latest version that is fetched from the GitHub API before automatically invalidating it and fetching it from the API again. This must be set to at least one hour (3600 seconds).
|
||||||
|
|
||||||
|
@ -126,10 +126,10 @@ EXEMPT_VIEW_PERMISSIONS = [
|
|||||||
|
|
||||||
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
|
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
|
||||||
# version check.
|
# version check.
|
||||||
GITHUB_REPOSITORY_API = 'https://api.github.com/repos/netbox-community/netbox'
|
UPDATE_REPO_URL = 'https://api.github.com/repos/netbox-community/netbox'
|
||||||
|
|
||||||
# This determines how often the GitHub API is called to check the latest release of NetBox. Must be at least 1 hour.
|
# This determines how often the GitHub API is called to check the latest release of NetBox. Must be at least 1 hour.
|
||||||
GITHUB_CACHE_TIMEOUT = 24 * 3600
|
UPDATE_CACHE_TIMEOUT = 24 * 3600
|
||||||
|
|
||||||
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
|
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
|
||||||
# https://docs.djangoproject.com/en/stable/topics/logging/
|
# https://docs.djangoproject.com/en/stable/topics/logging/
|
||||||
|
@ -80,9 +80,9 @@ DEVELOPER = getattr(configuration, 'DEVELOPER', False)
|
|||||||
EMAIL = getattr(configuration, 'EMAIL', {})
|
EMAIL = getattr(configuration, 'EMAIL', {})
|
||||||
ENFORCE_GLOBAL_UNIQUE = getattr(configuration, 'ENFORCE_GLOBAL_UNIQUE', False)
|
ENFORCE_GLOBAL_UNIQUE = getattr(configuration, 'ENFORCE_GLOBAL_UNIQUE', False)
|
||||||
EXEMPT_VIEW_PERMISSIONS = getattr(configuration, 'EXEMPT_VIEW_PERMISSIONS', [])
|
EXEMPT_VIEW_PERMISSIONS = getattr(configuration, 'EXEMPT_VIEW_PERMISSIONS', [])
|
||||||
GITHUB_REPOSITORY_API = getattr(configuration, 'GITHUB_REPOSITORY_API',
|
UPDATE_REPO_URL = getattr(configuration, 'UPDATE_REPO_URL',
|
||||||
'https://api.github.com/repos/netbox-community/netbox')
|
'https://api.github.com/repos/netbox-community/netbox')
|
||||||
GITHUB_CACHE_TIMEOUT = getattr(configuration, 'GITHUB_CACHE_TIMEOUT', 24 * 3600)
|
UPDATE_CACHE_TIMEOUT = getattr(configuration, 'UPDATE_CACHE_TIMEOUT', 24 * 3600)
|
||||||
LOGGING = getattr(configuration, 'LOGGING', {})
|
LOGGING = getattr(configuration, 'LOGGING', {})
|
||||||
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
||||||
LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None)
|
LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None)
|
||||||
@ -308,15 +308,15 @@ AUTHENTICATION_BACKENDS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# GitHub repository for version check
|
# GitHub repository for version check
|
||||||
if GITHUB_REPOSITORY_API:
|
if UPDATE_REPO_URL:
|
||||||
GITHUB_REPOSITORY_API = GITHUB_REPOSITORY_API.rstrip('/')
|
UPDATE_REPO_URL = UPDATE_REPO_URL.rstrip('/')
|
||||||
try:
|
try:
|
||||||
scheme, netloc, path, query, fragment = urlsplit(GITHUB_REPOSITORY_API)
|
scheme, netloc, path, query, fragment = urlsplit(UPDATE_REPO_URL)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ImproperlyConfigured("GITHUB_REPOSITORY_API must be a valid URL")
|
raise ImproperlyConfigured("UPDATE_REPO_URL must be a valid URL")
|
||||||
|
|
||||||
if scheme not in ('http', 'https'):
|
if scheme not in ('http', 'https'):
|
||||||
raise ImproperlyConfigured("GITHUB_REPOSITORY_API must be a valid http:// or https:// URL")
|
raise ImproperlyConfigured("UPDATE_REPO_URL must be a valid http:// or https:// URL")
|
||||||
|
|
||||||
if not re.fullmatch(r'/repos/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', path):
|
if not re.fullmatch(r'/repos/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', path):
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
@ -325,11 +325,11 @@ if GITHUB_REPOSITORY_API:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if query or fragment:
|
if query or fragment:
|
||||||
raise ImproperlyConfigured("GITHUB_REPOSITORY_API may not contain a query or fragment")
|
raise ImproperlyConfigured("UPDATE_REPO_URL may not contain a query or fragment")
|
||||||
|
|
||||||
# Enforce a cache timeout of at least an hour to protect GitHub
|
# Enforce a cache timeout of at least an hour to protect GitHub
|
||||||
if GITHUB_CACHE_TIMEOUT < 3600:
|
if UPDATE_CACHE_TIMEOUT < 3600:
|
||||||
raise ImproperlyConfigured("GITHUB_CACHE_TIMEOUT has to be at least 3600 seconds (1 hour)")
|
raise ImproperlyConfigured("UPDATE_CACHE_TIMEOUT has to be at least 3600 seconds (1 hour)")
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
@ -4,9 +4,9 @@ from django.conf import settings
|
|||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
|
|
||||||
@cached(timeout=settings.GITHUB_CACHE_TIMEOUT, extra=settings.GITHUB_REPOSITORY_API)
|
@cached(timeout=settings.UPDATE_CACHE_TIMEOUT, extra=settings.UPDATE_REPO_URL)
|
||||||
def get_releases(pre_releases=False):
|
def get_releases(pre_releases=False):
|
||||||
url = '{}/releases'.format(settings.GITHUB_REPOSITORY_API)
|
url = '{}/releases'.format(settings.UPDATE_REPO_URL)
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/vnd.github.v3+json',
|
'Accept': 'application/vnd.github.v3+json',
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ def get_releases(pre_releases=False):
|
|||||||
|
|
||||||
|
|
||||||
def get_latest_release(pre_releases=False):
|
def get_latest_release(pre_releases=False):
|
||||||
if settings.GITHUB_REPOSITORY_API:
|
if settings.UPDATE_REPO_URL:
|
||||||
releases = get_releases(pre_releases)
|
releases = get_releases(pre_releases)
|
||||||
if releases:
|
if releases:
|
||||||
return max(releases)
|
return max(releases)
|
||||||
|
Reference in New Issue
Block a user