-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from netboxlabs/develop
Release v0.4.0
- Loading branch information
Showing
17 changed files
with
362 additions
and
71 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,96 @@ | ||
name: Lint and tests | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- "!release" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
|
||
permissions: | ||
contents: write | ||
checks: write | ||
pull-requests: write | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
pip install .[dev] | ||
pip install .[test] | ||
- name: Build documentation | ||
run: mkdocs build | ||
- name: Run pycodestyle | ||
run: | | ||
pycodestyle --ignore=W504,E501 netbox_branching/ | ||
tests: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
strategy: | ||
matrix: | ||
python-version: [ "3.10", "3.11", "3.12" ] | ||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: netbox | ||
POSTGRES_PASSWORD: netbox | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
steps: | ||
- name: Checkout netbox-branching | ||
uses: actions/checkout@v4 | ||
with: | ||
path: netbox-branching | ||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Checkout netbox | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: "netbox-community/netbox" | ||
path: netbox | ||
- name: Install netbox-branching | ||
working-directory: netbox-branching | ||
run: | | ||
# Include tests directory for test | ||
sed -i 's/exclude-package-data/#exclude-package-data/g' pyproject.toml | ||
python -m pip install --upgrade pip | ||
pip install . | ||
pip install .[test] | ||
- name: Install dependencies & configure plugin | ||
working-directory: netbox | ||
run: | | ||
ln -s $(pwd)/../netbox-branching/testing/configuration.py netbox/netbox/configuration.py | ||
ln -s $(pwd)/../netbox-branching/testing/local_settings.py netbox/netbox/local_settings.py | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt -U | ||
- name: Run tests | ||
working-directory: netbox | ||
run: | | ||
python netbox/manage.py test netbox_branching.tests --keepdb |
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
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,17 @@ | ||
# Configuration Parameters | ||
|
||
## `max_branches` | ||
|
||
Default: None | ||
|
||
The maximum number of branches that can exist simultaneously, including merged branches that have not been deleted. It may be desirable to limit the total number of provisioned branches to safeguard against excessive database size. | ||
|
||
--- | ||
|
||
## `schema_prefix` | ||
|
||
Default: `branch_` | ||
|
||
The string to prefix to the unique branch ID when provisioning the PostgreSQL schema for a branch. Per [the PostgreSQL documentation](https://www.postgresql.org/docs/16/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS), this string must begin with a letter or underscore. | ||
|
||
Note that a valid prefix is required, as the randomly-generated branch ID alone may begin with a digit, which would not qualify as a valid schema name. |
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
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 |
---|---|---|
@@ -1,24 +1,49 @@ | ||
from django.conf import settings | ||
from django.core.exceptions import ImproperlyConfigured | ||
|
||
from netbox.plugins import PluginConfig | ||
from netbox.registry import registry | ||
|
||
|
||
class AppConfig(PluginConfig): | ||
name = 'netbox_branching' | ||
verbose_name = 'NetBox Branching' | ||
description = 'A git-like branching implementation for NetBox' | ||
version = '0.3.1' | ||
version = '0.4.0' | ||
base_url = 'branching' | ||
min_version = '4.1' | ||
middleware = [ | ||
'netbox_branching.middleware.BranchMiddleware' | ||
] | ||
default_settings = { | ||
# The maximum number of branches which can be provisioned simultaneously | ||
'max_branches': None, | ||
|
||
# This string is prefixed to the name of each new branch schema during provisioning | ||
'schema_prefix': 'branch_', | ||
} | ||
|
||
def ready(self): | ||
super().ready() | ||
from . import events, search, signal_receivers | ||
from . import constants, events, search, signal_receivers | ||
from .utilities import DynamicSchemaDict | ||
|
||
# Validate required settings | ||
if type(settings.DATABASES) is not DynamicSchemaDict: | ||
raise ImproperlyConfigured( | ||
"netbox_branching: DATABASES must be a DynamicSchemaDict instance." | ||
) | ||
if 'netbox_branching.database.BranchAwareRouter' not in settings.DATABASE_ROUTERS: | ||
raise ImproperlyConfigured( | ||
"netbox_branching: DATABASE_ROUTERS must contain 'netbox_branching.database.BranchAwareRouter'." | ||
) | ||
|
||
# Record all object types which support branching in the NetBox registry | ||
if 'branching' not in registry['model_features']: | ||
registry['model_features']['branching'] = { | ||
k: v for k, v in registry['model_features']['change_logging'].items() | ||
if k not in constants.EXCLUDED_APPS | ||
} | ||
|
||
|
||
config = AppConfig |
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
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
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
Oops, something went wrong.