Skip to content

Commit

Permalink
Merge pull request #137 from tamere-allo-peter/fix/issue-135
Browse files Browse the repository at this point in the history
fix: don't modify Ansible vaults. Closes #135.
  • Loading branch information
lyz-code authored Nov 26, 2021
2 parents 495162d + 86aa5c4 commit d0a5c6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/yamlfix/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def fix_code(source_code: str) -> str:
Returns:
Corrected source code.
"""
# Leave Ansible vaults unmodified
if source_code.startswith("$ANSIBLE_VAULT;"):
return source_code
fixers = [
_fix_truthy_strings,
_fix_comments,
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
]


def test_fix_code_ignore_ansible_vaults() -> None:
"""Adds the --- at the beginning of the source."""
source = dedent(
"""\
$ANSIBLE_VAULT;1.1;AES256
3036303361343731386530393763...
"""
)

result = fix_code(source)

assert result == source


def test_fix_code_adds_header() -> None:
"""Adds the --- at the beginning of the source."""
source = "program: yamlfix"
Expand Down

0 comments on commit d0a5c6b

Please sign in to comment.