Documentation
¶
Index ¶
- Constants
- type SeedComponent
- func (m *SeedComponent) AttachEnvironment(_ context.Context, _ *envite.Environment, writer *envite.Writer) error
- func (m *SeedComponent) Cleanup(context.Context) error
- func (m *SeedComponent) Config() any
- func (m *SeedComponent) Prepare(context.Context) error
- func (m *SeedComponent) Seed() error
- func (m *SeedComponent) Start(ctx context.Context) error
- func (m *SeedComponent) Status(context.Context) (envite.ComponentStatus, error)
- func (m *SeedComponent) Stop(context.Context) error
- func (m *SeedComponent) Type() string
- type SeedConfig
- type SeedTableData
Constants ¶
View Source
const ComponentType = "postgres seed"
ComponentType represents the type of the Postgres seed component.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SeedComponent ¶
type SeedComponent struct {
// contains filtered or unexported fields
}
SeedComponent is a component for seeding Postgres with data.
func NewSeedComponent ¶
func NewSeedComponent(config SeedConfig) *SeedComponent
NewSeedComponent creates a new SeedComponent instance.
func (*SeedComponent) AttachEnvironment ¶
func (m *SeedComponent) AttachEnvironment(_ context.Context, _ *envite.Environment, writer *envite.Writer) error
func (*SeedComponent) Config ¶
func (m *SeedComponent) Config() any
func (*SeedComponent) Seed ¶
func (m *SeedComponent) Seed() error
func (*SeedComponent) Status ¶
func (m *SeedComponent) Status(context.Context) (envite.ComponentStatus, error)
func (*SeedComponent) Type ¶
func (m *SeedComponent) Type() string
type SeedConfig ¶
type SeedConfig struct {
// ClientProvider - Provides a postgres client to use.
// available only via code, not available in config files.
ClientProvider func() (*sql.DB, error) `json:"-"`
// Setup - a string that contains the SQL setup script to run before seeding the data.
Setup string `json:"setup,omitempty"`
// Data - a list of objects, each represents a single postgres table and its data
Data []*SeedTableData `json:"data,omitempty"`
}
SeedConfig represents the configuration for the Postgres seed component.
type SeedTableData ¶
type SeedTableData struct {
// TableName - the name of the target postgres table
TableName string `json:"table_name,omitempty"`
// Rows - a list of rows to insert using the postgres Exec function (a `column` tag is required for each field):
Rows []any `json:"rows,omitempty"`
}
SeedTableData represents data for a Postgres table.
Click to show internal directories.
Click to hide internal directories.