diff --git a/docs/configuration/optional-settings.md b/docs/configuration/optional-settings.md index 5a3121960..652d10afc 100644 --- a/docs/configuration/optional-settings.md +++ b/docs/configuration/optional-settings.md @@ -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' -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). diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index b24db0f03..a90d286e7 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -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 # 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. -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: # https://docs.djangoproject.com/en/stable/topics/logging/ diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 43b5428f9..ce0ed7ce7 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -80,9 +80,9 @@ DEVELOPER = getattr(configuration, 'DEVELOPER', False) EMAIL = getattr(configuration, 'EMAIL', {}) ENFORCE_GLOBAL_UNIQUE = getattr(configuration, 'ENFORCE_GLOBAL_UNIQUE', False) EXEMPT_VIEW_PERMISSIONS = getattr(configuration, 'EXEMPT_VIEW_PERMISSIONS', []) -GITHUB_REPOSITORY_API = getattr(configuration, 'GITHUB_REPOSITORY_API', - 'https://api.github.com/repos/netbox-community/netbox') -GITHUB_CACHE_TIMEOUT = getattr(configuration, 'GITHUB_CACHE_TIMEOUT', 24 * 3600) +UPDATE_REPO_URL = getattr(configuration, 'UPDATE_REPO_URL', + 'https://api.github.com/repos/netbox-community/netbox') +UPDATE_CACHE_TIMEOUT = getattr(configuration, 'UPDATE_CACHE_TIMEOUT', 24 * 3600) LOGGING = getattr(configuration, 'LOGGING', {}) LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False) LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None) @@ -308,15 +308,15 @@ AUTHENTICATION_BACKENDS = [ ] # GitHub repository for version check -if GITHUB_REPOSITORY_API: - GITHUB_REPOSITORY_API = GITHUB_REPOSITORY_API.rstrip('/') +if UPDATE_REPO_URL: + UPDATE_REPO_URL = UPDATE_REPO_URL.rstrip('/') try: - scheme, netloc, path, query, fragment = urlsplit(GITHUB_REPOSITORY_API) + scheme, netloc, path, query, fragment = urlsplit(UPDATE_REPO_URL) 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'): - 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): raise ImproperlyConfigured( @@ -325,11 +325,11 @@ if GITHUB_REPOSITORY_API: ) 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 -if GITHUB_CACHE_TIMEOUT < 3600: - raise ImproperlyConfigured("GITHUB_CACHE_TIMEOUT has to be at least 3600 seconds (1 hour)") +if UPDATE_CACHE_TIMEOUT < 3600: + raise ImproperlyConfigured("UPDATE_CACHE_TIMEOUT has to be at least 3600 seconds (1 hour)") # Internationalization LANGUAGE_CODE = 'en-us' diff --git a/netbox/utilities/releases.py b/netbox/utilities/releases.py index 6fb422c00..30ee8c295 100644 --- a/netbox/utilities/releases.py +++ b/netbox/utilities/releases.py @@ -4,9 +4,9 @@ from django.conf import settings 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): - url = '{}/releases'.format(settings.GITHUB_REPOSITORY_API) + url = '{}/releases'.format(settings.UPDATE_REPO_URL) headers = { 'Accept': 'application/vnd.github.v3+json', } @@ -27,7 +27,7 @@ def get_releases(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) if releases: return max(releases)