config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Profiles       map[string]Profile `yaml:"profiles"`
	DefaultProfile string             `yaml:"default_profile"`
}

Config holds all configuration profiles for Tusk.

func Load

func Load() (*Config, error)

Load reads the Tusk configuration. It tries, in order:

  1. ~/.config/tusk/config.yaml
  2. DATABASE_URL environment variable
  3. PG* environment variables (PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE)
  4. Sensible defaults (localhost:5432, user postgres)

func (*Config) ResolveProfile

func (c *Config) ResolveProfile(name string) (Profile, error)

ResolveProfile returns the named profile from the config. If name is empty, the default profile is used. If no profiles are configured, a profile is built from environment variables and defaults.

type Profile

type Profile struct {
	Host            string             `yaml:"host"`
	Port            int                `yaml:"port"`
	User            string             `yaml:"user"`
	Password        string             `yaml:"password"`
	Database        string             `yaml:"database"`
	SSLMode         string             `yaml:"sslmode"`
	URL             string             `yaml:"url"`
	Readonly        bool               `yaml:"readonly"`
	Color           string             `yaml:"color"`
	RefreshInterval time.Duration      `yaml:"refresh_interval"`
	Rules           []rules.RuleConfig `yaml:"rules"`
}

Profile represents a single PostgreSQL connection profile.

func (Profile) ConnectionString

func (p Profile) ConnectionString() string

ConnectionString returns a PostgreSQL connection string for this profile. If URL is set directly, it is returned as-is. Otherwise, the string is assembled from the individual fields.

Jump to

Keyboard shortcuts

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