mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
fix(yaml): tolerate ansible-vault tags in the shared loader
The cached YAML loader crashed on the !vault tag with a ConstructorError, so any lint test that walks the tree and parses every .yml (yaml-syntax, role/group-vars usage, ...) failed as soon as a vault-encrypted inventory was present. Register a !vault constructor on SafeLoader that loads the ciphertext as a plain scalar, mirroring the existing !override/!reset handling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ff463b7b6a
commit
2ac6c0878d
2 files changed
+8
-4
No files matched your search
@@ -23,10 +23,7 @@ class TestYamlSyntax(unittest.TestCase):
|
||||
invalid.append((full, f"Unexpected error: {e}"))
|
||||
|
||||
if invalid:
|
||||
msg_lines = [
|
||||
f"{path}: {err.splitlines()[0]}" # just the first line of the error
|
||||
for path, err in invalid
|
||||
]
|
||||
msg_lines = [f"{path}: {err.splitlines()[0]}" for path, err in invalid]
|
||||
self.fail(
|
||||
"Found invalid YAML in the following files:\n" + "\n".join(msg_lines)
|
||||
)
|
||||
|
||||
Vendored
+7
@@ -50,6 +50,13 @@ def _construct_compose_merge_tag(loader, node):
|
||||
for _tag in ("!override", "!reset"):
|
||||
yaml.SafeLoader.add_constructor(_tag, _construct_compose_merge_tag)
|
||||
|
||||
|
||||
def _construct_vault_tag(loader, node):
|
||||
return loader.construct_scalar(node)
|
||||
|
||||
|
||||
yaml.SafeLoader.add_constructor("!vault", _construct_vault_tag)
|
||||
|
||||
_MISSING = object()
|
||||
_CACHE: dict[tuple[str, int, int], list[Any]] = {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user