fix: import DATABASE from configuration instead of env vars
All checks were successful
Build and Push Docker Images / build (push) Successful in 7s

This commit is contained in:
2026-01-07 15:02:55 +00:00
parent b60a3f0b1e
commit 71e980fd8c

View File

@@ -2,24 +2,20 @@
# NetBox Local Settings for netbox-branching plugin # NetBox Local Settings for netbox-branching plugin
# ============================================================================= # =============================================================================
# This file configures DynamicSchemaDict required by netbox-branching. # This file configures DynamicSchemaDict required by netbox-branching.
# It wraps the DATABASE configuration from the parent configuration.py # It imports DATABASE from the NetBox Docker configuration and wraps it.
# ============================================================================= # =============================================================================
import os import sys
from netbox_branching.utilities import DynamicSchemaDict from netbox_branching.utilities import DynamicSchemaDict
# Add the config directory to Python path to import DATABASE
sys.path.insert(0, '/etc/netbox/config')
from configuration import DATABASE
# Wrap DATABASES with DynamicSchemaDict for dynamic schema support # Wrap DATABASES with DynamicSchemaDict for dynamic schema support
# This is required for netbox-branching plugin to function correctly # This is required for netbox-branching plugin to function correctly
DATABASES = DynamicSchemaDict({ DATABASES = DynamicSchemaDict({
'default': { 'default': DATABASE,
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME', 'netbox'),
'USER': os.environ.get('DB_USER', 'netbox'),
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', ''),
'CONN_MAX_AGE': int(os.environ.get('DB_CONN_MAX_AGE', 300)),
}
}) })
# Employ the custom database router for branch-aware queries # Employ the custom database router for branch-aware queries