diff --git a/docs/colliecting-diffs.md b/docs/colliecting-diffs.md index 565c0bf..e9a9bef 100644 --- a/docs/colliecting-diffs.md +++ b/docs/colliecting-diffs.md @@ -42,6 +42,9 @@ If you have configs in NetBox DataSource, you can define it, the script instead !!! note Only synced DataSources are acceptable +!!! note + Diff replaces sequences of 3 or more empty lines with one empty line + If in your DataSource config names are different from the hostnames of the devices, you can specify config name with Jinja2 template in `Name template` field. Reference device with `{{ object }}` variable. diff --git a/netbox_config_diff/compliance/utils.py b/netbox_config_diff/compliance/utils.py index 7451a71..53a5801 100644 --- a/netbox_config_diff/compliance/utils.py +++ b/netbox_config_diff/compliance/utils.py @@ -40,8 +40,8 @@ def __init__(self, choices, *args, **kwargs): def get_unified_diff(rendered_config: str, actual_config: str, device: str) -> str: diff = unified_diff( - actual_config.splitlines(), - rendered_config.strip().splitlines(), + re.sub("\n{3,}", "\n", actual_config).splitlines(), + re.sub("\n{3,}", "\n", rendered_config).strip().splitlines(), fromfiledate=device, tofiledate=device, lineterm="",