Documentation
¶
Index ¶
- func List() error
- func Start(input StartInput) error
- func Status() error
- func Stop(input StopInput) error
- type BastionConfig
- type ClustersConfig
- type ConnConfig
- type ConnTypeConfig
- type DefaultConfig
- type EnvConfig
- type ResolvedConnection
- type RuntimeEntry
- type RuntimeState
- type ServiceConfig
- type StartInput
- type StopInput
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.
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.