Documentation
¶
Index ¶
- func CreatedDatabase(log logging.Logger) (err error)
- func CreatedDatabaseWithConfig(log logging.Logger, conf *Config) (err error)
- func GenerateRandomPassword(length int) string
- func RunMigrations(mode Mode) error
- func RunMigrationsWithConfig(conf *DBConfig, mode Mode) error
- type BaseConfig
- type Config
- type DBConfig
- type Mode
- type PostgresAdmin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatedDatabase ¶
func GenerateRandomPassword ¶
func RunMigrations ¶
func RunMigrationsWithConfig ¶
Types ¶
type BaseConfig ¶
type BaseConfig struct {
DBHost string `envconfig:"PG_DB_HOST" required:"true"`
DBPort string `envconfig:"PG_DB_PORT" required:"true"`
DBAdminCredIdentifier string `envconfig:"PG_DB_ADMIN_CRED_IDENTIFIER" default:"postgres-admin"`
EntityName string `envconfig:"PG_DB_ENTITY_NAME" default:"postgres"`
}
type Config ¶
type Config struct {
BaseConfig
DBName string `envconfig:"PG_DB_NAME" required:"false"`
DBServiceUsername string `envconfig:"PG_DB_SERVICE_USERNAME" required:"false"`
Password string `envconfig:"PG_DB_SERVICE_USERPASSWORD" required:"false"`
AdminPassword string `envconfig:"PG_DB_ADMIN_PASSWORD" required:"false"`
}
type DBConfig ¶
type DBConfig struct {
DBHost string `envconfig:"PG_DB_HOST" required:"true"`
DBPort string `envconfig:"PG_DB_PORT" default:"5432"`
DBName string `envconfig:"PG_DB_NAME" required:"true"`
EntityName string `envconfig:"PG_DB_ENTITY_NAME" default:"postgres"`
Username string `envconfig:"PG_DB_SERVICE_USERNAME" required:"true"`
Password string `envconfig:"PG_DB_SERVICE_USERPASSWORD" required:"false"`
SourceURI string `envconfig:"PG_SOURCE_URI" default:"file:///postgres/migrations"`
}
type PostgresAdmin ¶
type PostgresAdmin struct {
// contains filtered or unexported fields
}
func NewPostgresAdmin ¶
func NewPostgresAdmin(logger logging.Logger, dbAddr, dbAdminUsername, dbAdminPassword string) (*PostgresAdmin, error)
func (*PostgresAdmin) CreateDb ¶
func (p *PostgresAdmin) CreateDb(dbName string) (err error)
func (*PostgresAdmin) CreateDbUser ¶
func (p *PostgresAdmin) CreateDbUser(serviceUsername string, servicePassword string) (err error)
func (*PostgresAdmin) GrantPermission ¶
func (p *PostgresAdmin) GrantPermission(serviceUsername string, dbAddr, dbAdminUsername, dbAdminPassword, dbName string) error
func (*PostgresAdmin) Session ¶
func (p *PostgresAdmin) Session() *gorm.DB
Click to show internal directories.
Click to hide internal directories.