pyvolt-cli 0.5.1__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyvolt-cli
3
- Version: 0.5.1
3
+ Version: 0.7.0
4
4
  Summary: The command-line companion to Pyvolt: managed Python deployments on infrastructure you actually own.
5
5
  Project-URL: Homepage, https://pyvolt.com
6
6
  Project-URL: Repository, https://github.com/pyvolt-hq/pyvolt-cli
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyvolt-cli"
7
- version = "0.5.1"
7
+ version = "0.7.0"
8
8
  description = "The command-line companion to Pyvolt: managed Python deployments on infrastructure you actually own."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -581,3 +581,120 @@ def open_(
581
581
  return
582
582
  console.print(f"Opening {site['dashboard_url']}")
583
583
  webbrowser.open(site["dashboard_url"])
584
+
585
+
586
+ # ---- SSH keys (#75) -----------------------------------------------------------
587
+
588
+ keys_app = typer.Typer(help="Manage the SSH public keys pushed to your servers.", no_args_is_help=True)
589
+ app.add_typer(keys_app, name="keys")
590
+
591
+
592
+ @keys_app.command("list")
593
+ def keys_list():
594
+ """List your SSH public keys."""
595
+ data = Api().get("/v1/ssh-keys")
596
+ if _emit(data):
597
+ return
598
+ if not data:
599
+ console.print("No SSH keys yet. Add one with [bold]pyvolt keys add[/bold].")
600
+ return
601
+ t = _table("ID", "NAME", "FINGERPRINT")
602
+ for k in data:
603
+ t.add_row(str(k["id"]), k["name"], k["fingerprint"])
604
+ console.print(t)
605
+
606
+
607
+ @keys_app.command("add")
608
+ def keys_add(
609
+ path: str = typer.Argument(None, metavar="PATH", help="Public key file (default: ~/.ssh/id_ed25519.pub)."),
610
+ name: str = typer.Option(None, "--name", "-n", help="Label for the key (default: its comment, else your hostname)."),
611
+ ):
612
+ """Add an SSH public key. Pushed to every ready server in your account."""
613
+ import socket
614
+ from pathlib import Path
615
+
616
+ p = Path(path).expanduser() if path else Path.home() / ".ssh" / "id_ed25519.pub"
617
+ if not p.exists():
618
+ raise fail(f"No public key at {p}. Pass a path, e.g. [bold]pyvolt keys add ~/.ssh/id_rsa.pub[/bold].")
619
+ pub = p.read_text().strip()
620
+ if not name:
621
+ parts = pub.split()
622
+ name = parts[2] if len(parts) >= 3 else socket.gethostname()
623
+ r = Api().post("/v1/ssh-keys", json={"name": name, "public_key": pub}, ok=(201, 422))
624
+ if r.status_code == 422:
625
+ raise fail(r.json().get("detail", "That doesn't look like an SSH public key."))
626
+ key = r.json()
627
+ if _emit(key):
628
+ return
629
+ console.print(f"[green]✓[/green] Added [bold]{key['name']}[/bold] ({key['fingerprint']}). Syncing to your servers.")
630
+
631
+
632
+ @keys_app.command("rm")
633
+ def keys_rm(key_id: int = typer.Argument(..., metavar="ID", help="Key ID from `pyvolt keys list`.")):
634
+ """Remove an SSH public key by ID."""
635
+ Api().delete(f"/v1/ssh-keys/{key_id}")
636
+ console.print(f"[green]✓[/green] Removed key {key_id}. Re-syncing your servers.")
637
+
638
+
639
+ @apps_app.command("export-config")
640
+ def apps_export_config(
641
+ app_name: str = typer.Argument(..., metavar="DOMAIN"),
642
+ write: bool = typer.Option(
643
+ False, "--write", "-w", help="Write ./pyvolt.toml instead of printing it."
644
+ ),
645
+ ):
646
+ """Generate a pyvolt.toml from the app's current settings (ADR-0012).
647
+
648
+ Commit the file to manage this app's deploy config from the repo. Its keys
649
+ then override the dashboard on every deploy; omitted keys keep their current
650
+ values."""
651
+ from pathlib import Path
652
+
653
+ api = Api()
654
+ site = api.resolve_app(app_name)
655
+ body = api.get(f"/v1/apps/{site['id']}/config")
656
+ if _emit(body):
657
+ return
658
+ toml = body["toml"]
659
+ if not write:
660
+ # Raw stdout (no Rich markup/wrapping) so `> pyvolt.toml` is byte-clean.
661
+ print(toml, end="")
662
+ return
663
+ p = Path("pyvolt.toml")
664
+ if p.exists():
665
+ raise fail("pyvolt.toml already exists here — remove it first, or drop --write to print.")
666
+ p.write_text(toml)
667
+ console.print(
668
+ f"[green]✓ Wrote pyvolt.toml[/] ({len(toml.splitlines())} lines). "
669
+ "Commit it to manage this app's deploy config from the repo."
670
+ )
671
+
672
+
673
+ config_app = typer.Typer(
674
+ help="Validate and export pyvolt.toml (repo deploy config).", no_args_is_help=True
675
+ )
676
+ app.add_typer(config_app, name="config")
677
+
678
+
679
+ @config_app.command("validate")
680
+ def config_validate(
681
+ path: str = typer.Argument("pyvolt.toml", help="Path to the file to validate."),
682
+ ):
683
+ """Check a local pyvolt.toml against the server's schema — the SAME check the
684
+ deploy runs, so a pass here means the deploy won't reject it."""
685
+ from pathlib import Path
686
+
687
+ p = Path(path)
688
+ if not p.exists():
689
+ raise fail(f"No file at [bold]{path}[/bold].")
690
+ body = Api().post("/v1/config/validate", json={"text": p.read_text()}).json()
691
+ if _emit(body):
692
+ return
693
+ if body["valid"]:
694
+ managed = ", ".join(body.get("managed") or []) or "nothing"
695
+ console.print(f"[green]✓ {path} is valid.[/] It manages: {managed}")
696
+ return
697
+ console.print(f"[red]✗ {path} has problems:[/]")
698
+ for err in body["errors"]:
699
+ console.print(f" • {err}")
700
+ raise typer.Exit(1)
File without changes
File without changes
File without changes