ansible-vars 1.0.15__py3-none-any.whl → 1.0.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ansible_vars/cli.py +5 -2
- ansible_vars/util.py +2 -3
- ansible_vars/vault.py +4 -3
- ansible_vars/vault_crypt.py +7 -2
- {ansible_vars-1.0.15.dist-info → ansible_vars-1.0.17.dist-info}/METADATA +1 -1
- ansible_vars-1.0.17.dist-info/RECORD +13 -0
- ansible_vars-1.0.15.dist-info/RECORD +0 -13
- {ansible_vars-1.0.15.dist-info → ansible_vars-1.0.17.dist-info}/WHEEL +0 -0
- {ansible_vars-1.0.15.dist-info → ansible_vars-1.0.17.dist-info}/entry_points.txt +0 -0
- {ansible_vars-1.0.15.dist-info → ansible_vars-1.0.17.dist-info}/licenses/LICENSE +0 -0
ansible_vars/cli.py
CHANGED
@@ -505,9 +505,12 @@ def print_yaml(code: str) -> None:
|
|
505
505
|
return std_print(code)
|
506
506
|
std_print(highlight(code, yaml_highlight_lexer, highlight_formatter).strip('\n'))
|
507
507
|
|
508
|
-
def print_diff(diff: str) -> None:
|
508
|
+
def print_diff(diff: str | None) -> None:
|
509
509
|
'''Print a diff with highlighting if a `color_mode` is available.'''
|
510
510
|
_color_map: dict = { '-': Color.TREE_REMOVED, '+': Color.TREE_ADDED, '@': Color.INFO, '*': Color.TREE_UNCHANGED }
|
511
|
+
if not diff:
|
512
|
+
print('Vaults are identical.', Color.TREE_UNCHANGED)
|
513
|
+
return
|
511
514
|
for line in diff.split('\n'):
|
512
515
|
color: Color = _color_map[line[0]] if (len(line) > 0 and line[0] in [ '-', '+', '@' ]) else _color_map['*']
|
513
516
|
print(line, color)
|
@@ -707,7 +710,7 @@ if config.command in [ 'create', 'edit' ]:
|
|
707
710
|
new_editable: str = edit_file.read()
|
708
711
|
if editable != new_editable:
|
709
712
|
try:
|
710
|
-
new_vault
|
713
|
+
new_vault = VaultFile.from_editable(vault, new_editable)
|
711
714
|
except YAMLFormatError as e:
|
712
715
|
print('Invalid YAML format:', Color.BAD)
|
713
716
|
print(e.parent if e.parent else e, Color.BAD)
|
ansible_vars/util.py
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# Standard library imports
|
4
4
|
import os, atexit
|
5
5
|
from glob import glob
|
6
|
-
from pathlib import Path
|
7
6
|
from functools import wraps
|
8
7
|
from datetime import datetime
|
9
8
|
from typing import Callable
|
@@ -38,7 +37,7 @@ class DiffLogger():
|
|
38
37
|
You can specify an optional comment string which will be included.
|
39
38
|
'''
|
40
39
|
# Check if any changes happened
|
41
|
-
diff:
|
40
|
+
diff: str | None = curr_vault.diff(prev_vault, context_lines=0, show_filenames=True)
|
42
41
|
if not force and not diff:
|
43
42
|
return None
|
44
43
|
# Build entry
|
@@ -55,7 +54,7 @@ class DiffLogger():
|
|
55
54
|
# Diff
|
56
55
|
lines.append('DIFF')
|
57
56
|
if diff:
|
58
|
-
lines += diff
|
57
|
+
lines += diff.split('\n')
|
59
58
|
else:
|
60
59
|
lines.append('No changes.')
|
61
60
|
#lines.append(OUTER_SEP)
|
ansible_vars/vault.py
CHANGED
@@ -208,7 +208,7 @@ class Vault():
|
|
208
208
|
def has(self, path: DictPath) -> bool:
|
209
209
|
'''Checks if the given key path is present in the vault's data.'''
|
210
210
|
try: self._traverse(path, decrypt=False)
|
211
|
-
except KeyError: return False
|
211
|
+
except ( KeyError, IndexError ): return False
|
212
212
|
return True
|
213
213
|
|
214
214
|
def get(
|
@@ -591,12 +591,13 @@ class Vault():
|
|
591
591
|
|
592
592
|
# Comparing to older versions of this vault
|
593
593
|
|
594
|
-
def diff(self, prev_vault: 'Vault', context_lines: int = 3, show_filenames: bool = True) -> str:
|
594
|
+
def diff(self, prev_vault: 'Vault', context_lines: int = 3, show_filenames: bool = True) -> str | None:
|
595
595
|
'''
|
596
596
|
Generates a diff for the edit mode Jinja2 YAML vault code (from `Vault.as_editable`) of a previous vault to this one's.
|
597
597
|
Set `context_lines` to specify how many lines of context are shown before and after the actual diff lines.
|
598
598
|
If `show_filenames` is set to True and the vaults are `VaultFile` objects,
|
599
599
|
the previous and current filenames will be shown in the diff header.
|
600
|
+
If there is no difference between the vaults, None is returned.
|
600
601
|
'''
|
601
602
|
# Generate filenames
|
602
603
|
prev_filename: str = 'Previous vault'
|
@@ -615,7 +616,7 @@ class Vault():
|
|
615
616
|
n = context_lines,
|
616
617
|
lineterm = ''
|
617
618
|
)
|
618
|
-
)
|
619
|
+
) or None # diff function returns empty list if there are no changes, even skipping the header
|
619
620
|
|
620
621
|
def changes(self, prev_vault: 'Vault') -> tuple[ChangeList, ChangeList, ChangeList, ChangeList]:
|
621
622
|
'''
|
ansible_vars/vault_crypt.py
CHANGED
@@ -206,8 +206,13 @@ class VaultKeyring():
|
|
206
206
|
# XXX Hacky, but the right-hand path from loading a vault ID like 'vaultid@get-password.sh' will be resolved from CWD
|
207
207
|
# Could possibly be avoided by splitting the detected vault IDs and transforming any right-hand paths
|
208
208
|
with chdir(pardir):
|
209
|
-
|
210
|
-
|
209
|
+
# Seems version-dependent if `initialize_context` is recognized and required
|
210
|
+
try:
|
211
|
+
secrets: list[tuple[str | None, VaultSecret]] = \
|
212
|
+
CLI.setup_vault_secrets(DataLoader(), vault_ids, auto_prompt=False, initialize_context=False) # type: ignore
|
213
|
+
except TypeError:
|
214
|
+
secrets: list[tuple[str | None, VaultSecret]] = \
|
215
|
+
CLI.setup_vault_secrets(DataLoader(), vault_ids, auto_prompt=False)
|
211
216
|
return list(map(VaultKey.from_ansible_secret, secrets))
|
212
217
|
|
213
218
|
def __repr__(self) -> str:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
ansible_vars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
ansible_vars/cli.py,sha256=cp891u9-kZoJireRIsTh-zy_9cTZPifLio2U7NqRoQM,66428
|
3
|
+
ansible_vars/constants.py,sha256=VNr78qbzdJ0Vn0psbzjjQngNG3VbHhk6NXTz30VNUno,1622
|
4
|
+
ansible_vars/errors.py,sha256=6dzyksPKWira9O2-Ir3MIOwr4XjN9MSBiRp5e6siY6Q,1256
|
5
|
+
ansible_vars/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
ansible_vars/util.py,sha256=NJ_qufelfe0m4i80sb81PYYbbkVhoHNcpkJdl8XYpTQ,21241
|
7
|
+
ansible_vars/vault.py,sha256=pBZVz64qdj1vstC9rZBIJ3O9n-_AHhhbySN1Q7eMWho,47199
|
8
|
+
ansible_vars/vault_crypt.py,sha256=ZXa6QywyWdRVhY3YkFuk-COYs50MG252uakqe3bUUog,12116
|
9
|
+
ansible_vars-1.0.17.dist-info/METADATA,sha256=-OQpTFwCeOawRVBI1HV_oG2Jlxbmb52GKkQ2pskSCbk,21071
|
10
|
+
ansible_vars-1.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
ansible_vars-1.0.17.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
|
12
|
+
ansible_vars-1.0.17.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
|
13
|
+
ansible_vars-1.0.17.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
ansible_vars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
ansible_vars/cli.py,sha256=D2_gUY3u3EpeP4T76YTez9n9gUrBySPwFRyKcrW2auI,66339
|
3
|
-
ansible_vars/constants.py,sha256=VNr78qbzdJ0Vn0psbzjjQngNG3VbHhk6NXTz30VNUno,1622
|
4
|
-
ansible_vars/errors.py,sha256=6dzyksPKWira9O2-Ir3MIOwr4XjN9MSBiRp5e6siY6Q,1256
|
5
|
-
ansible_vars/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
ansible_vars/util.py,sha256=UwGPBT19pee7lBpWuBzLPAvcrHUBAn6i1MrJvzM9OQ4,21265
|
7
|
-
ansible_vars/vault.py,sha256=F8Eyn8ebduC3Cmst07280Bt7Wmy293ZRt9QrwshVVCA,47011
|
8
|
-
ansible_vars/vault_crypt.py,sha256=Hv_bBn6gazVAnfo-h2ufsg1qAdaPB_Lvpicjl-rR-r8,11818
|
9
|
-
ansible_vars-1.0.15.dist-info/METADATA,sha256=LAixHYmmBpn82kfAGuBR16Xt3FbRG6plmEI1o1y1vlk,21071
|
10
|
-
ansible_vars-1.0.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
-
ansible_vars-1.0.15.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
|
12
|
-
ansible_vars-1.0.15.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
|
13
|
-
ansible_vars-1.0.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|