Skip to content

Commit

Permalink
Closes #84: Strip a lot of newlines in configs (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
miaow2 authored Nov 9, 2024
1 parent a57aead commit 6cdf1eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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

0 comments on commit 6cdf1eb

Please sign in to comment.