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 #84: Strip a lot of newlines in configs #85

Merged
merged 2 commits into from
Nov 9, 2024
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
3 changes: 3 additions & 0 deletions docs/colliecting-diffs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions netbox_config_diff/compliance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand Down
Loading