INNER CODE UNIT · Python
cloudflare_tunnel_id
onedr0p/cluster-template · template/scripts/plugin.py:50
def cloudflare_tunnel_id(file_path: str = 'cloudflare-tunnel.json') -> str:
data = _read_json(file_path)
tunnel_id = data.get("TunnelID")
if tunnel_id is None:
raise KeyError(f"Missing 'TunnelID' key in {file_path}")
if not tunnel_id:
raise ValueError(f"'TunnelID' is empty in {file_path}")
return tunnel_id
# Return cloudflare tunnel fields from cloudflare-tunnel.json in TUNNEL_TOKEN format
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}")