Skip to content
File

Blob: scripts/prepare_secrets.py

python25 lines
1#!/usr/bin/env python3
2"""Initialize device/viewer credentials and refresh the local worker/.dev.vars export."""
3import argparse
4 
5from credentials import initialize_credentials, sync_worker_secrets
6from project import ROOT
7 
8 
9def main(argv=None):
10 parser = argparse.ArgumentParser(description=__doc__)
11 parser.add_argument("--sync", action="store_true", help="Refresh worker/.dev.vars from existing credentials")
12 parser.add_argument("--if-present", action="store_true", help="Allow --sync to skip a checkout with no private files")
13 args = parser.parse_args(argv)
14 if args.if_present and not args.sync:
15 parser.error("--if-present requires --sync")
16 if args.sync:
17 sync_worker_secrets(ROOT, optional=args.if_present)
18 else:
19 initialize_credentials(ROOT)
20 print("Credentials are ready in .credential.env; worker/.dev.vars is a generated export.")
21 
22 
23if __name__ == "__main__":
24 main()