Skip to content

feat: first-run setup screen + VPC-aware connection management (#11)#12

Merged
Fraser-Isbester merged 2 commits into
mainfrom
feat/onboarding-and-connect
Jul 8, 2026
Merged

feat: first-run setup screen + VPC-aware connection management (#11)#12
Fraser-Isbester merged 2 commits into
mainfrom
feat/onboarding-and-connect

Conversation

@Fraser-Isbester

Copy link
Copy Markdown
Owner

What

Makes tusk easy to start against real (VPC) databases.

Onboarding. When no connection can be established — no config, an unknown profile (tusk -P nope), or an unreachable DB — tusk opens an interactive setup screen instead of a cobra error + exit. It validates the connection with a real Ping, optionally saves it as a profile (comment-preserving), and drops straight into the TUI. Next launch connects through.

Connectivity. New TUI-free internal/connect package turns a profile into a reachable DSN, establishing a tunnel first and tearing it down on exit:

  • direct (default) — URL/fields as-is.
  • kube-port-forward — spawns kubectl port-forward into a cluster (GKE), waits for the local port, connects, kills the process group on exit.
  • exec — arbitrary tunnel command (SSH bastion, cloud-sql-proxy, …) with {local_port} substitution.

Both tusk and the tuskd daemon use it, so headless enforcement works against VPC DBs too.

Config gains a connect: block + omitempty on Profile; SaveProfile persists via the same comment-preserving YAML-node edit as SaveProfileRules (and carries existing rules over).

Why

Issue #11 — direct Postgres-over-the-internet is the exception; the databases worth watching live inside a VPC. This gets people into the TUI in one screen instead of a second terminal juggling port-forwards.

Validation

  • go build ./..., go vet ./..., golangci-lint run ./... (0 issues), go test -race ./...; go mod tidy clean.
  • Unit tests: connect dispatch/argv/{local_port}/freePort/waitForPort (incl. process-death) + spawn/teardown; SaveProfile round-trips (comments, omitempty, rules preserved).
  • End-to-end vs local Postgres (PTY): unresolved-profile → setup → connect → profile saved (comment intact) → into the TUI; second run connects straight through; and an exec tunnel (stand-in forwarder) drove tuskd against the real DB and cleaned the process up on exit.

Review guide

  • internal/connect/{connect,methods}.go — tunnel establishment + teardown.
  • internal/tui/setup.go — the setup screen.
  • cmd/tusk/main.goestablish → setup fallback.
  • internal/config/config.goConnectConfig, SaveProfile.

Closes #11

Make tusk easy to start against real databases.

Onboarding: when a connection can't be established — no config, an unknown
profile, or an unreachable DB — tusk now opens an interactive setup screen
instead of printing a cobra error and exiting. The user enters a connection
(or a tunnel), tusk validates it with a real Ping, optionally saves it as a
profile (comment-preserving), and drops straight into the TUI. Subsequent
launches connect through.

Connectivity: new TUI-free internal/connect package turns a profile into a
reachable DSN, establishing a tunnel first when needed and tearing it down on
exit. Methods:
  - direct (default): use the URL/fields as-is.
  - kube-port-forward: spawn `kubectl port-forward` into a cluster (GKE), wait
    for the local port, connect, kill the process group on exit.
  - exec: run an arbitrary tunnel command (SSH bastion, cloud-sql-proxy, …)
    with {local_port} substitution.
Both tusk and the tuskd daemon use it, so headless enforcement works against
VPC databases too.

Config gains a `connect:` block (ConnectConfig) and omitempty on Profile
fields; SaveProfile persists a profile via the same comment-preserving YAML
node edit as SaveProfileRules, carrying existing rules over.

Tests: connect method dispatch, kube argv, {local_port} substitution,
freePort/waitForPort (incl. process-death), and spawn/teardown; SaveProfile
round-trips. Verified end-to-end against local Postgres: direct onboarding
saves a working profile and re-runs connect through, and an exec tunnel
(via a stand-in forwarder) drives tuskd against a real DB and cleans up.

Closes #11
@Fraser-Isbester Fraser-Isbester merged commit 8b6df55 into main Jul 8, 2026
6 checks passed
@Fraser-Isbester Fraser-Isbester deleted the feat/onboarding-and-connect branch July 8, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First-run onboarding + VPC-aware connection management

1 participant