Documentation
¶
Index ¶
- func RunMigrations(dsn string) error
- type FileStateAdapter
- func (a *FileStateAdapter) GetEnvironment(ctx context.Context, name string) (*domain.EnvironmentEntry, error)
- func (a *FileStateAdapter) Load(_ context.Context) (*domain.State, error)
- func (a *FileStateAdapter) RemoveEnvironment(ctx context.Context, name string) error
- func (a *FileStateAdapter) Save(_ context.Context, state *domain.State) error
- func (a *FileStateAdapter) SetEnvironment(ctx context.Context, name string, entry *domain.EnvironmentEntry) error
- type PostgresStateAdapter
- func (a *PostgresStateAdapter) Close() error
- func (a *PostgresStateAdapter) GetEnvironment(ctx context.Context, name string) (*domain.EnvironmentEntry, error)
- func (a *PostgresStateAdapter) Load(ctx context.Context) (*domain.State, error)
- func (a *PostgresStateAdapter) RemoveEnvironment(ctx context.Context, name string) error
- func (a *PostgresStateAdapter) Save(ctx context.Context, state *domain.State) error
- func (a *PostgresStateAdapter) SetEnvironment(ctx context.Context, name string, entry *domain.EnvironmentEntry) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunMigrations ¶
RunMigrations applies all pending goose migrations from the embedded SQL files. Should be called explicitly via `previewctl migrate` before first use.
Types ¶
type FileStateAdapter ¶
type FileStateAdapter struct {
// contains filtered or unexported fields
}
FileStateAdapter persists state to a JSON file with atomic writes.
func NewFileStateAdapter ¶
func NewFileStateAdapter(path string) *FileStateAdapter
NewFileStateAdapter creates a new file-based state adapter.
func (*FileStateAdapter) GetEnvironment ¶
func (a *FileStateAdapter) GetEnvironment(ctx context.Context, name string) (*domain.EnvironmentEntry, error)
func (*FileStateAdapter) RemoveEnvironment ¶
func (a *FileStateAdapter) RemoveEnvironment(ctx context.Context, name string) error
func (*FileStateAdapter) SetEnvironment ¶
func (a *FileStateAdapter) SetEnvironment(ctx context.Context, name string, entry *domain.EnvironmentEntry) error
type PostgresStateAdapter ¶
type PostgresStateAdapter struct {
// contains filtered or unexported fields
}
PostgresStateAdapter persists state to a PostgreSQL database. Each environment is stored as a JSONB row, scoped by project name. Deleted environments are hard-deleted from the database. Run RunMigrations before first use to ensure the schema is up to date.
func NewPostgresStateAdapter ¶
func NewPostgresStateAdapter(dsn, project string) (*PostgresStateAdapter, error)
NewPostgresStateAdapter creates a new Postgres-backed state adapter. The dsn should be a valid PostgreSQL connection string. The project name scopes state so multiple projects can share one database. The caller should run RunMigrations separately (via `previewctl migrate`) before using the adapter for the first time.
func (*PostgresStateAdapter) Close ¶
func (a *PostgresStateAdapter) Close() error
Close closes the underlying database connection.
func (*PostgresStateAdapter) GetEnvironment ¶
func (a *PostgresStateAdapter) GetEnvironment(ctx context.Context, name string) (*domain.EnvironmentEntry, error)
func (*PostgresStateAdapter) RemoveEnvironment ¶
func (a *PostgresStateAdapter) RemoveEnvironment(ctx context.Context, name string) error
func (*PostgresStateAdapter) SetEnvironment ¶
func (a *PostgresStateAdapter) SetEnvironment(ctx context.Context, name string, entry *domain.EnvironmentEntry) error