Documentation
¶
Index ¶
- Constants
- type ConnectionConfig
- type FoundFile
- type Group
- type OSPathHandler
- type PathHandler
- type ScrubRule
- type SyncConfig
- type SyncHistory
- type SyncHistoryEntry
- type SyncProfile
- type SyncProfiles
- type TableEntry
- type TableHistoryEntry
- type UserConfigHandler
- func (uc *UserConfigHandler) DeleteProfile(name string) error
- func (uc *UserConfigHandler) GetConnection(name string) (ConnectionConfig, error)
- func (uc *UserConfigHandler) GetProfile(nameOrPath string) (SyncProfile, error)
- func (uc *UserConfigHandler) InitConnection(name string) error
- func (uc *UserConfigHandler) ListConnections() ([]string, error)
- func (uc *UserConfigHandler) ListProfileFiles() ([]FoundFile, error)
- func (uc *UserConfigHandler) ListSyncConfigs() ([]FoundFile, error)
- func (uc *UserConfigHandler) LoadProfiles() (SyncProfiles, error)
- func (uc *UserConfigHandler) LoadSyncHistory() (SyncHistory, error)
- func (uc *UserConfigHandler) ResolveProfilePath(nameOrPath string) (string, error)
- func (uc *UserConfigHandler) ResolveSyncConfigPath(nameOrPath string) (string, error)
- func (uc *UserConfigHandler) SaveConnection(name string, conn ConnectionConfig) error
- func (uc *UserConfigHandler) SaveProfile(p SyncProfile) error
- func (uc *UserConfigHandler) SaveSyncHistory(entry SyncHistoryEntry) error
Constants ¶
const ProjectConfigDir = ".pggosync"
ProjectConfigDir is the project-local directory searched before the user config dir, so teams can commit shared sync configs and profiles to a repo.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
User string `yaml:"user"`
Password string `yaml:"password"`
SSLMode string `yaml:"sslmode,omitempty"`
}
ConnectionConfig holds credentials for a single database.
type FoundFile ¶
type FoundFile struct {
Name string // filename without extension
Path string
Origin string // "project" or "user"
}
FoundFile is a named YAML file discovered in one of the search directories.
type Group ¶
type Group struct {
Tables []TableEntry `yaml:"tables"`
}
type OSPathHandler ¶
type OSPathHandler struct{}
func (OSPathHandler) UserConfigDir ¶
func (ph OSPathHandler) UserConfigDir() (string, error)
UserConfigDir delegates to os.UserConfigDir to locate the OS-level user configuration directory.
type PathHandler ¶
type SyncConfig ¶
type SyncConfig struct {
Description string `yaml:"description"`
Exclude []string `yaml:"exclude"`
Groups map[string]Group `yaml:"groups"`
}
func GetSyncConfig ¶
func GetSyncConfig(syncConfigPath string) (SyncConfig, error)
GetSyncConfig reads and unmarshals a sync config YAML file, returning a descriptive error on missing or invalid files.
type SyncHistory ¶
type SyncHistory struct {
Entries []SyncHistoryEntry `json:"entries"`
}
type SyncHistoryEntry ¶
type SyncHistoryEntry struct {
Timestamp time.Time `json:"timestamp"`
Source string `json:"source"`
Dest string `json:"dest"`
ConfigFile string `json:"config_file"`
Tables []TableHistoryEntry `json:"tables"`
TotalRows int64 `json:"total_rows"`
DryRun bool `json:"dry_run"`
Error string `json:"error,omitempty"`
}
type SyncProfile ¶
type SyncProfile struct {
Name string `json:"name" yaml:"-"`
Source string `json:"source" yaml:"source"`
Dest string `json:"dest" yaml:"dest"`
ConfigFile string `json:"config_file" yaml:"config_file"`
Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
RawTableInput string `json:"raw_table_input,omitempty" yaml:"raw_table_input,omitempty"`
Truncate bool `json:"truncate,omitempty" yaml:"truncate,omitempty"`
Preserve bool `json:"preserve,omitempty" yaml:"preserve,omitempty"`
DeferConstraints bool `json:"defer_constraints,omitempty" yaml:"defer_constraints,omitempty"`
DisableTriggers bool `json:"disable_triggers,omitempty" yaml:"disable_triggers,omitempty"`
Concurrency int `json:"concurrency" yaml:"concurrency"`
DryRun bool `json:"dry_run,omitempty" yaml:"dry_run,omitempty"`
NoSafety bool `json:"no_safety,omitempty" yaml:"no_safety,omitempty"`
CreatedAt time.Time `json:"created_at" yaml:"created_at,omitempty"`
}
SyncProfile is a named bundle of sync options stored as one YAML file per profile in a profiles search directory. Name comes from the filename stem and is never written into the file. The json tags exist only to read the legacy profiles.json during migration.
type SyncProfiles ¶
type SyncProfiles struct {
Profiles []SyncProfile `json:"profiles"`
}
type TableEntry ¶
type TableHistoryEntry ¶
type UserConfigHandler ¶
type UserConfigHandler struct {
PathHandler PathHandler
}
func NewUserConfigHandler ¶
func NewUserConfigHandler(pathHandler PathHandler) *UserConfigHandler
NewUserConfigHandler creates a UserConfigHandler backed by the given PathHandler.
func (*UserConfigHandler) DeleteProfile ¶
func (uc *UserConfigHandler) DeleteProfile(name string) error
DeleteProfile removes a profile file from the user profiles directory. Project-local profiles are files in the repo and are not touched.
func (*UserConfigHandler) GetConnection ¶
func (uc *UserConfigHandler) GetConnection(name string) (ConnectionConfig, error)
GetConnection loads a named connection config.
func (*UserConfigHandler) GetProfile ¶
func (uc *UserConfigHandler) GetProfile(nameOrPath string) (SyncProfile, error)
GetProfile resolves a profile name or path and loads it.
func (*UserConfigHandler) InitConnection ¶
func (uc *UserConfigHandler) InitConnection(name string) error
InitConnection creates a placeholder connection file.
func (*UserConfigHandler) ListConnections ¶
func (uc *UserConfigHandler) ListConnections() ([]string, error)
ListConnections returns the names of all saved connections.
func (*UserConfigHandler) ListProfileFiles ¶
func (uc *UserConfigHandler) ListProfileFiles() ([]FoundFile, error)
ListProfileFiles enumerates profiles in the search directories.
func (*UserConfigHandler) ListSyncConfigs ¶
func (uc *UserConfigHandler) ListSyncConfigs() ([]FoundFile, error)
ListSyncConfigs enumerates sync configs in the search directories.
func (*UserConfigHandler) LoadProfiles ¶
func (uc *UserConfigHandler) LoadProfiles() (SyncProfiles, error)
LoadProfiles returns all profiles found in the search directories, migrating the legacy profiles.json first if present.
func (*UserConfigHandler) LoadSyncHistory ¶
func (uc *UserConfigHandler) LoadSyncHistory() (SyncHistory, error)
LoadSyncHistory reads the history file from disk; returns an empty SyncHistory if the file does not exist.
func (*UserConfigHandler) ResolveProfilePath ¶
func (uc *UserConfigHandler) ResolveProfilePath(nameOrPath string) (string, error)
ResolveProfilePath resolves a profile name or path to a file path.
func (*UserConfigHandler) ResolveSyncConfigPath ¶
func (uc *UserConfigHandler) ResolveSyncConfigPath(nameOrPath string) (string, error)
ResolveSyncConfigPath resolves a sync config name or path to a file path.
func (*UserConfigHandler) SaveConnection ¶
func (uc *UserConfigHandler) SaveConnection(name string, conn ConnectionConfig) error
SaveConnection writes a connection config to disk.
func (*UserConfigHandler) SaveProfile ¶
func (uc *UserConfigHandler) SaveProfile(p SyncProfile) error
SaveProfile writes a profile to <user profiles dir>/<name>.yaml.
func (*UserConfigHandler) SaveSyncHistory ¶
func (uc *UserConfigHandler) SaveSyncHistory(entry SyncHistoryEntry) error
SaveSyncHistory appends entry to the history file, trimming to the last maxHistoryEntries entries.