Documentation
¶
Overview ¶
Package metaldb is the resource module for MetalDB — self-managed PostgreSQL provisioned over SSH onto a customer VM.
It wraps the two node endpoints the web dashboard's Metal DB wizard calls:
POST /api/v2/tenant/provision/metaldb/test-connection (multipart) POST /api/v2/tenant/provision/metaldb (JSON)
The SSH private key is never sent by the client — the node resolves it from the workspace vault by KeyPairName. The client only supplies which VM, how to log into it, and the Postgres user/password to create.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the entry point. Construct via c.MetalDB().
func (*Client) Provision ¶
Provision installs PostgreSQL on the target VM and creates the requested database/user. This endpoint runs the install synchronously, so the returned Result already carries status / connection_string / outputs.
func (*Client) TestConnection ¶
TestConnection pre-flights the SSH connection to the target VM — the equivalent of the wizard's "Test SSH Connection" button. HTTP is always 200; inspect the "success" field of the returned Result.
type ProvisionInput ¶
type ProvisionInput struct {
SSH SSH
// ResourceName labels the deployment; defaults to DatabaseName.
ResourceName string
// CloudProvider tag; defaults to "metaldb".
CloudProvider string
DatabaseName string // default "postgres"
DatabaseUser string // default "postgres"
DatabasePassword string // default "root"
PostgresPassword string // default "root"
Port string // default "5432"
PostgresVersion string // default "16"
EnableReplication bool
ReplicaHostname string
MultiZone bool
BackupEnabled bool // dashboard default: true (see DefaultProvisionInput)
BackupRetention int // days; dashboard default: 7
Tags map[string]string
}
ProvisionInput is the body for Provision. Use DefaultProvisionInput to start from the same defaults the web dashboard applies.
func DefaultProvisionInput ¶
func DefaultProvisionInput() ProvisionInput
DefaultProvisionInput returns a ProvisionInput pre-filled with the same defaults the web dashboard's Metal DB wizard uses. Set SSH and any overrides, then pass it to Provision.
type SSH ¶
type SSH struct {
Host string // target VM IP or DNS name (required)
User string // SSH login user, e.g. "ubuntu" or "root" (required)
KeyPairName string // workspace vault key entry, e.g. "VPS1" (required)
// WorkspaceUser overrides the workspace owner used for vault path
// resolution. Defaults to the authenticated user.
WorkspaceUser string
// Organization overrides the org segment of the vault path.
Organization string
}
SSH identifies the target VM and how to log into it. The private key itself is resolved server-side from the workspace vault by KeyPairName.