Added helper function to load file content as base64
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
# Adapted from: https://enix.io/en/blog/pxe-talos/
|
||||
|
||||
import base64
|
||||
import functools
|
||||
import json
|
||||
import pathlib
|
||||
@@ -71,6 +72,9 @@ def tailscale_subnet(gateway: str, netmask: str):
|
||||
netmask_bits = IPAddress(netmask).netmask_bits()
|
||||
return f"{IPAddress(gateway) & IPAddress(netmask)}/{netmask_bits}"
|
||||
|
||||
def load_secret(path: str):
|
||||
with open(path) as f:
|
||||
return base64.b64encode(f.read().encode()).decode()
|
||||
|
||||
@functools.cache
|
||||
def get_schematic_id(schematic: str):
|
||||
@@ -165,7 +169,7 @@ def main():
|
||||
template_args = {
|
||||
"config": config,
|
||||
"root": ROOT,
|
||||
"helper": {"tailscale_subnet": tailscale_subnet},
|
||||
"helper": {"tailscale_subnet": tailscale_subnet, "load_secret": load_secret},
|
||||
}
|
||||
|
||||
nodes = []
|
||||
|
||||
Reference in New Issue
Block a user