connect

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() error

List prints all connections that can be derived from the config by combining every service with every environment.

func Start

func Start(input StartInput) error

Start launches a new SSM tunnel for the given type+name.

func Status

func Status() error

Status prints the current state of all tracked tunnels, verifying each PID is alive.

func Stop

func Stop(input StopInput) error

Stop terminates active tunnels based on the input:

  • DBType="" → stop all active connections
  • DBType set, Name="" → stop all active connections of that type
  • DBType set, Name set → stop that specific connection

Types

type BastionConfig

type BastionConfig struct {
	Target  string `yaml:"target"`
	Profile string `yaml:"profile"`
	Region  string `yaml:"region"`
}

BastionConfig holds the SSM bastion access parameters.

type ClustersConfig

type ClustersConfig struct {
	RDS   string `yaml:"rds"`
	Cache string `yaml:"cache"`
	DocDB string `yaml:"docdb"`
}

ClustersConfig holds the host-suffix fragments for each engine in one environment.

type ConnConfig

type ConnConfig struct {
	Defaults     map[string]DefaultConfig  `yaml:"defaults"`
	Environments map[string]EnvConfig      `yaml:"environments"`
	Connections  map[string]ConnTypeConfig `yaml:"connections"`
}

ConnConfig is the top-level structure of the YAML config file (~/.draft/dbconnect.yml).

func (ConnConfig) ResolveConnection

func (cfg ConnConfig) ResolveConnection(dbType, name string) (ResolvedConnection, error)

ResolveConnection builds a ResolvedConnection from (dbType, name) where name = "{service}-{env}", e.g. "turbo-dev" or "turbo-prod".

type ConnTypeConfig

type ConnTypeConfig struct {
	Instances []ServiceConfig `yaml:"instances"`
}

ConnTypeConfig holds the instance list for one DB type.

type DefaultConfig

type DefaultConfig struct {
	RemotePort int `yaml:"remote_port"`
}

DefaultConfig holds per-type defaults (e.g. remote port).

type EnvConfig

type EnvConfig struct {
	Bastion  BastionConfig  `yaml:"bastion"`
	Clusters ClustersConfig `yaml:"clusters"`
}

EnvConfig holds the bastion and cluster suffixes for one environment.

type ResolvedConnection

type ResolvedConnection struct {
	DBType     string
	Name       string // full CLI name, e.g. "turbo-dev"
	Service    string // e.g. "turbo"
	Env        string // "dev" or "prod"
	Bastion    BastionConfig
	Host       string
	RemotePort int
	LocalPort  int
}

ResolvedConnection contains all values needed to open an SSM tunnel, computed at runtime from (dbType, name) where name = "{service}-{env}".

type RuntimeEntry

type RuntimeEntry struct {
	DBType     string    `json:"db_type"`
	Name       string    `json:"name"`
	Env        string    `json:"env"`
	PID        int       `json:"pid"`
	LocalPort  int       `json:"local_port"`
	RemotePort int       `json:"remote_port"`
	Host       string    `json:"host"`
	StartedAt  time.Time `json:"started_at"`
}

RuntimeEntry holds runtime metadata for an active tunnel.

type RuntimeState

type RuntimeState struct {
	Connections map[string]RuntimeEntry `json:"connections"`
}

RuntimeState holds the persisted state of active tunnels.

type ServiceConfig

type ServiceConfig struct {
	Name       string         `yaml:"name"`
	LocalPorts map[string]int `yaml:"local_ports"`
}

ServiceConfig is a single instance entry inside a DB type. LocalPorts maps environment name → local port, e.g. {"dev": 56000, "prod": 56011}.

type StartInput

type StartInput struct {
	DBType    string
	Name      string // "{service}-{env}", e.g. "turbo-dev"
	LocalPort int    // 0 means use the default computed from config
}

StartInput holds parameters for starting a tunnel.

type StopInput

type StopInput struct {
	DBType string // empty = all types
	Name   string // empty = all within type
}

StopInput holds parameters for stopping one or more tunnels.

Jump to

Keyboard shortcuts

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