metaldb

package
v0.1.0-preview Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

type Client struct {
	T              *transport.Transport
	NodeURL        string
	AuthedUsername string
}

Client is the entry point. Construct via c.MetalDB().

func (*Client) Provision

func (c *Client) Provision(ctx context.Context, in ProvisionInput) (Result, error)

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

func (c *Client) TestConnection(ctx context.Context, ssh SSH) (Result, error)

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 Result

type Result = map[string]interface{}

Result is a decoded JSON object response.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL