INNER CODE UNIT · Python
cloudflare_tunnel_secret
onedr0p/cluster-template · template/scripts/plugin.py:61
def cloudflare_tunnel_secret(file_path: str = 'cloudflare-tunnel.json') -> str:
data = _read_json(file_path)
for field in ("AccountTag", "TunnelID", "TunnelSecret"):
if field not in data:
raise KeyError(f"Missing '{field}' key in {file_path}")
if not data[field]:
raise ValueError(f"'{field}' is empty in {file_path}")
transformed_data = {
"a": data["AccountTag"],
"t": data["TunnelID"],
"s": data["TunnelSecret"]
}
json_string = json.dumps(transformed_data, separators=(',', ':'))
return base64.b64encode(json_string.encode('utf-8')).decode('utf-8')
# Return the Flux deploy key from deploy.key
def deploy_key(file_path: str = 'deploy.key') -> str: