From ba165ab4a46ac85269ea373f5ca3935f2e6d6f78 Mon Sep 17 00:00:00 2001 From: William Tan <1284324+Ninja3047@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:44:25 -0500 Subject: [PATCH] Add --region flag to wake command for cross-region restores Allow overriding the snapshot's original region when waking a hibernated droplet. Falls back to snapshot metadata, or errors with an actionable hint if neither is available. Co-Authored-By: Claude Opus 4.6 --- .gitignore | 1 + dropkit/main.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index aa16a07..29ebe65 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ dropkit/_version.txt # Git worktrees .worktrees/ +.claude/worktrees # Claude Code local settings .claude/settings.local.json diff --git a/dropkit/main.py b/dropkit/main.py index 442131b..f3a346e 100644 --- a/dropkit/main.py +++ b/dropkit/main.py @@ -3914,6 +3914,9 @@ def wake( ..., autocompletion=complete_snapshot_name, help="Name of the hibernated droplet to restore" ), no_tailscale: bool = typer.Option(False, "--no-tailscale", help="Skip Tailscale VPN re-setup"), + region: str | None = typer.Option( + None, "--region", "-r", help="Region slug (default: snapshot's original region)" + ), ): """ Wake a hibernated droplet (restore from snapshot). @@ -3979,8 +3982,17 @@ def wake( elif tag == "tailscale-lockdown": was_tailscale_locked = True - if not original_region: + # Determine region: explicit flag > snapshot metadata > error + if region: + restore_region = region + elif original_region: + restore_region = original_region + else: console.print("[red]Error: Could not determine original region from snapshot[/red]") + console.print( + f"[dim]Specify a region explicitly: " + f"[cyan]dropkit wake {droplet_name} --region [/cyan][/dim]" + ) raise typer.Exit(1) if not original_size: @@ -3992,9 +4004,12 @@ def wake( # Display snapshot info console.print(f"Found hibernated snapshot: [cyan]{snapshot_name}[/cyan] ({size_gb} GB)") + original_display = original_region or "[yellow]unknown[/yellow]" console.print( - f"Original config: [cyan]{original_region}[/cyan], [cyan]{original_size}[/cyan]" + f"Original config: [cyan]{original_display}[/cyan], [cyan]{original_size}[/cyan]" ) + if region and region != original_region: + console.print(f"Region override: [cyan]{region}[/cyan]") console.print() # Create droplet from snapshot @@ -4005,7 +4020,7 @@ def wake( droplet = api.create_droplet_from_snapshot( name=droplet_name, - region=original_region, + region=restore_region, size=original_size, snapshot_id=snapshot_id, tags=tags_list,