fix(health-agent): skip uk_tokens.yml write when tokens dict is empty to prevent setup skip loop

This commit is contained in:
Murat ÖZDEMİR 2026-06-26 21:10:10 +03:00
parent 8b10653ff4
commit e4acd0e57b

View File

@ -370,10 +370,13 @@ def setup_uptime_kuma(dry_run=False, only=None):
# 7. Write push tokens to uk_tokens.yml
token_file = os.path.join(os.path.dirname(__file__), "..", "config", "generated", "uk_tokens.yml")
if not dry_run:
os.makedirs(os.path.dirname(token_file), exist_ok=True)
with open(token_file, "w") as f:
yaml.dump(tokens, f)
logger.info(f"Saved push tokens to {token_file}")
if not tokens:
logger.warning("No push tokens captured; skipping uk_tokens.yml write so setup reruns next time")
else:
os.makedirs(os.path.dirname(token_file), exist_ok=True)
with open(token_file, "w") as f:
yaml.dump(tokens, f)
logger.info(f"Saved {len(tokens)} push tokens to {token_file}")
else:
logger.info(f"[DRY-RUN] Would save {len(tokens)} tokens to {token_file}")