feat: talos_patches makejinja func and move certain patches to patches directory (#1509)

This commit is contained in:
Devin Buhl authored and GitHub committed 2024-06-04 09:55:57 -04:00
1 parent 6fd9c17bb7
commit f397a7d09c
15 files changed
+143 -148

No files matched your search

+19 -1
View File
@@ -11,6 +11,20 @@ import makejinja
import validation
# Return the filename of a path without the j2 extension
def basename(value: str) -> str:
return Path(value).stem
# Return a list of files in the talos patches directory
def talos_patches(value: str) -> list[str]:
path = Path(f'bootstrap/templates/kubernetes/bootstrap/talos/patches/{value}')
if not path.is_dir():
return []
return [str(f) for f in path.glob('*.yaml.j2') if f.is_file()]
# Return the nth host in a CIDR range
def nthhost(value: str, query: int) -> str:
value = IPNetwork(value)
try:
@@ -50,7 +64,11 @@ class Plugin(makejinja.plugin.Plugin):
def filters(self) -> makejinja.plugin.Filters:
return [nthhost]
return [basename, nthhost]
def functions(self) -> makejinja.plugin.Functions:
return [talos_patches]
def path_filters(self):