Documentation
¶
Index ¶
- func GetPassword(service api.Service, role string) (string, error)
- type ConnectionDetails
- type ConnectionDetailsOptions
- type KeyringStorage
- func (k *KeyringStorage) Get(service api.Service, role string) (string, error)
- func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (k *KeyringStorage) Remove(service api.Service, role string) error
- func (k *KeyringStorage) Save(service api.Service, password string, role string) error
- type NoStorage
- func (n *NoStorage) Get(service api.Service, role string) (string, error)
- func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (n *NoStorage) Remove(service api.Service, role string) error
- func (n *NoStorage) Save(service api.Service, password string, role string) error
- type PasswordStorage
- type PasswordStorageResult
- type PgpassStorage
- func (p *PgpassStorage) Get(service api.Service, role string) (string, error)
- func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult
- func (p *PgpassStorage) Remove(service api.Service, role string) error
- func (p *PgpassStorage) Save(service api.Service, password string, role string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectionDetails ¶ added in v0.8.0
type ConnectionDetails struct {
Role string `json:"role,omitempty" yaml:"role,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"`
Database string `json:"database,omitempty" yaml:"database,omitempty"`
IsPooler bool `json:"is_pooler,omitempty" yaml:"is_pooler,omitempty"`
}
func GetConnectionDetails ¶ added in v0.8.0
func GetConnectionDetails(service api.Service, opts ConnectionDetailsOptions) (*ConnectionDetails, error)
func (*ConnectionDetails) String ¶ added in v0.8.0
func (d *ConnectionDetails) String() string
String creates a PostgreSQL connection string from service details
type ConnectionDetailsOptions ¶ added in v0.8.0
type ConnectionDetailsOptions struct {
// Pooled determines whether to use the pooler endpoint (if available)
Pooled bool
// Role is the database role/username to use (e.g., "tsdbadmin")
Role string
// WithPassword determines whether to include the password in the output
WithPassword bool
// InitialPassword is an optional password to use directly (e.g., from service creation response)
// If provided and WithPassword is true, this password will be used
// instead of fetching from password storage. This is useful when password_storage=none.
InitialPassword string
}
ConnectionDetailsOptions configures how the connection string is built
type KeyringStorage ¶
type KeyringStorage struct{}
KeyringStorage implements password storage using system keyring
func (*KeyringStorage) GetStorageResult ¶
func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult
type NoStorage ¶
type NoStorage struct{}
NoStorage implements no password storage (passwords are not saved)
func (*NoStorage) GetStorageResult ¶
func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult
type PasswordStorage ¶
type PasswordStorage interface {
Save(service api.Service, password string, role string) error
Get(service api.Service, role string) (string, error)
Remove(service api.Service, role string) error
GetStorageResult(err error, password string) PasswordStorageResult
}
PasswordStorage defines the interface for password storage implementations
func GetPasswordStorage ¶
func GetPasswordStorage() PasswordStorage
GetPasswordStorage returns the appropriate PasswordStorage implementation based on configuration
type PasswordStorageResult ¶
type PasswordStorageResult struct {
Success bool `json:"success"`
Method string `json:"method"` // "keyring", "pgpass", or "none"
Message string `json:"message"` // Human-readable message
}
PasswordStorageResult contains the result of password storage operations
func SavePasswordWithResult ¶
func SavePasswordWithResult(service api.Service, password string, role string) (PasswordStorageResult, error)
SavePasswordWithResult handles saving a password and returns both error and result info
type PgpassStorage ¶
type PgpassStorage struct{}
PgpassStorage implements password storage using ~/.pgpass file
func (*PgpassStorage) GetStorageResult ¶
func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult