prole/mock_val/sync-prole-cfg.py

28 lines
807 B
Python

#!/usr/bin/env python3
import sys
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parents[1]
sys.path.append(str(ROOT_DIR))
from knoe import config as inst_config
from knoe.core.onepassword import get_secret, op_available
def main():
token = ""
if op_available():
token = get_secret("k3s-token", "credential").strip()
if token:
print("Syncing K3S_TOKEN to conf/knoe.cfg...")
inst_config._update_knoe_cfg_value("Global", "PROLE_K3S_TOKEN", token)
inst_config._update_knoe_cfg_value("Inputs", "init_cluster.k3s_token", token)
inst_config._update_knoe_cfg_value("Service Cluster (k3s)", "K3S_TOKEN", token)
else:
print("Warning: Could not retrieve k3s-token from 1Password knoey vault.")
if __name__ == "__main__":
main()