Skip to content

Update code to remove use of deprecated PluginCustomValidator class. #199

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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 changes/181.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced all occurrences of PluginCustomValidator with CustomValidator.
12 changes: 6 additions & 6 deletions nautobot_data_validation_engine/custom_validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This is the meat of this app.

Here we dynamically generate a PluginCustomValidator class
Here we dynamically generate a CustomValidator class
for each model currently registered in the extras_features
query registry 'custom_validators'.

Expand All @@ -23,7 +23,7 @@
from nautobot.core.utils.data import render_jinja2
from nautobot.extras.datasources import ensure_git_repository
from nautobot.extras.models import GitRepository
from nautobot.extras.plugins import CustomValidator, PluginCustomValidator
from nautobot.extras.plugins import CustomValidator
from nautobot.extras.registry import registry

from nautobot_data_validation_engine.models import (
Expand All @@ -38,8 +38,8 @@
LOGGER = logging.getLogger(__name__)


class BaseValidator(PluginCustomValidator):
"""Base PluginCustomValidator class that implements the core logic for enforcing validation rules defined in this app."""
class BaseValidator(CustomValidator):
"""Base CustomValidator class that implements the core logic for enforcing validation rules defined in this app."""

model = None

Expand Down Expand Up @@ -304,10 +304,10 @@ def compliance_result(self, message, attribute=None, valid=True):


class CustomValidatorIterator:
"""Iterator that generates PluginCustomValidator classes for each model registered in the extras feature query registry 'custom_validators'."""
"""Iterator that generates CustomValidator classes for each model registered in the extras feature query registry 'custom_validators'."""

def __iter__(self):
"""Return a generator of PluginCustomValidator classes for each registered model."""
"""Return a generator of CustomValidator classes for each registered model."""
for app_label, models in registry["model_features"]["custom_validators"].items():
for model in models:
yield type(
Expand Down
2 changes: 1 addition & 1 deletion nautobot_data_validation_engine/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run(self, *args, **kwargs):
for compliance_class in compliance_classes:
if selected_data_compliance_rules and compliance_class.__name__ not in selected_data_compliance_rules:
continue
logger.info(f"Running {compliance_class.__name__}")
logger.info("Running %s", compliance_class.__name__)
app_label, model = compliance_class.model.split(".")
for obj in global_apps.get_model(app_label, model).objects.all():
ins = compliance_class(obj)
Expand Down
4 changes: 2 additions & 2 deletions nautobot_data_validation_engine/template_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def detail_tabs(self):


class ComplianceTemplateIterator:
"""Iterator that generates PluginCustomValidator classes for each model registered in the extras feature query registry 'custom_validators'."""
"""Iterator that generates CustomValidator classes for each model registered in the extras feature query registry 'custom_validators'."""

def __iter__(self):
"""Return a generator of PluginCustomValidator classes for each registered model."""
"""Return a generator of CustomValidator classes for each registered model."""
for app_label, models in registry["model_features"]["custom_validators"].items():
for model in models:
label = f"{app_label}.{model}"
Expand Down