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

Closes #17857: Add release_track attribute to PluginConfig #18562

Merged
merged 1 commit into from
Feb 3, 2025
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
1 change: 1 addition & 0 deletions docs/plugins/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ NetBox looks for the `config` variable within a plugin's `__init__.py` to load i
| `name` | Raw plugin name; same as the plugin's source directory |
| `verbose_name` | Human-friendly name for the plugin |
| `version` | Current release ([semantic versioning](https://semver.org/) is encouraged) |
| `release_track` | An alternate release track (e.g. `dev` or `beta`) to which a release belongs |
| `description` | Brief description of the plugin's purpose |
| `author` | Name of plugin's author |
| `author_email` | Author's public email address |
Expand Down
5 changes: 4 additions & 1 deletion netbox/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def get_local_plugins(plugins=None):
for plugin_name in settings.PLUGINS:
plugin = importlib.import_module(plugin_name)
plugin_config: PluginConfig = plugin.config
installed_version = plugin_config.version
if plugin_config.release_track:
installed_version = f'{installed_version}-{plugin_config.release_track}'

local_plugins[plugin_config.name] = Plugin(
config_name=plugin_config.name,
Expand All @@ -88,7 +91,7 @@ def get_local_plugins(plugins=None):
description_short=plugin_config.description,
is_local=True,
is_installed=True,
installed_version=plugin_config.version,
installed_version=installed_version,
)

# Update catalog entries for local plugins, or add them to the list if not listed
Expand Down
1 change: 1 addition & 0 deletions netbox/netbox/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PluginConfig(AppConfig):
author_email = ''
description = ''
version = ''
release_track = ''

# Root URL path under /plugins. If not set, the plugin's label will be used.
base_url = None
Expand Down
5 changes: 4 additions & 1 deletion netbox/netbox/plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def get_installed_plugins():
for plugin_name in settings.PLUGINS:
plugin_name = plugin_name.rsplit('.', 1)[-1]
plugin_config = apps.get_app_config(plugin_name)
plugins[plugin_name] = getattr(plugin_config, 'version', None)
if plugin_config.release_track:
plugins[plugin_name] = f'{plugin_config.version}-{plugin_config.release_track}'
else:
plugins[plugin_name] = plugin_config.version or None

return dict(sorted(plugins.items()))

Expand Down
3 changes: 2 additions & 1 deletion netbox/netbox/plugins/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def _get_plugin_data(plugin_app_config):
'author': plugin_app_config.author,
'author_email': plugin_app_config.author_email,
'description': plugin_app_config.description,
'version': plugin_app_config.version
'version': plugin_app_config.version,
'release_track': plugin_app_config.release_track,
}

def get(self, request, format=None):
Expand Down