Files
recipe-maintainer/scripts/switch_default_instance.py
autonomic-bot f283a371bb recipe-maintainer: public snapshot (secrets + deployment plans removed, single commit)
Sanitized single-commit public mirror of recipe-maintainer.
- Removed test-ssh/.testenv (live creds); added test-ssh/.testenv.example placeholders.
- Removed plans/ and planned-updates/ (deployment-planning docs) so no client/
  deployment domains appear in the public repo.
- All other secret stores were already gitignored.
- docs.coopcloud.tech retained as a submodule (public upstream).
2026-06-16 20:18:24 +00:00

60 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Switch the default instance used by all skills.
Usage:
python3 scripts/switch_default_instance.py <instance-name>
python3 scripts/switch_default_instance.py # lists available instances
"""
import argparse
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib.config import get_instance_names, get_default_instance_name, paths
def main():
parser = argparse.ArgumentParser(description="Switch the default instance")
parser.add_argument("instance", nargs="?", help="Instance name to switch to")
args = parser.parse_args()
instances = get_instance_names()
current = get_default_instance_name()
if not args.instance:
print(f"Current default: {current}")
print(f"Available instances: {', '.join(instances)}")
sys.exit(0)
if args.instance not in instances:
print(f"Error: '{args.instance}' is not a valid instance.")
print(f"Available instances: {', '.join(instances)}")
sys.exit(1)
if args.instance == current:
print(f"Already set to '{current}', nothing to do.")
sys.exit(0)
settings_path = paths.WORKSPACE / "settings.toml"
text = settings_path.read_text()
new_text = text.replace(
f'default_instance = "{current}"',
f'default_instance = "{args.instance}"',
)
settings_path.write_text(new_text)
# Verify
# Re-import to bust any caches wouldn't work, so just read back
verify = settings_path.read_text()
if f'default_instance = "{args.instance}"' in verify:
print(f"Switched default instance: {current} -> {args.instance}")
else:
print("Error: failed to update settings.toml")
sys.exit(1)
if __name__ == "__main__":
main()