Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateDSN(secret *corev1.Secret) string
- func GetSecretKV(secret *corev1.Secret, key string) string
- type DatabaseServer
- func (s *DatabaseServer) Close(ctx context.Context) error
- func (s *DatabaseServer) Connect(ctx context.Context) error
- func (s *DatabaseServer) CopyInitConfigToSecret(dbAccount *dbov1.DatabaseAccount, secret *corev1.Secret)
- func (s *DatabaseServer) CreateDatabase(ctx context.Context, dbName, roleName string) (string, error)
- func (s *DatabaseServer) CreateRole(ctx context.Context, roleName string) (string, string, error)
- func (s *DatabaseServer) CreateSchema(ctx context.Context, schemaName, roleName string) error
- func (s *DatabaseServer) Delete(ctx context.Context, name string) error
- func (s *DatabaseServer) GetDatabaseHost(dbAccount *dbov1.DatabaseAccount) string
- func (s *DatabaseServer) GetDatabaseHostConfig() string
- func (s *DatabaseServer) IsDatabase(ctx context.Context, dbName string) (string, bool, error)
- func (s *DatabaseServer) IsRole(ctx context.Context, roleName string) (bool, error)
- func (s *DatabaseServer) ListUsers(ctx context.Context) []string
- func (s *DatabaseServer) UpdateRolePassword(ctx context.Context, roleName string) (string, string, error)
- type Server
Constants ¶
View Source
const ( DatabaseKeyDSN = "dsn" DatabaseKeyUsername = "username" DatabaseKeyPassword = "password" DatabaseKeyHost = "host" DatabaseKeyPort = "port" DatabaseKeySchema = "schema" DatabaseKeyDatabase = "database" DatabaseKeyOnDelete = "onDelete" DatabaseKeyPGBouncerConf = "pgbouncer.ini" DatabaseKeyPGBouncerUsers = "userlist.txt" )
Variables ¶
View Source
var (
ErrRoleExists = errors.New("role already exists")
)
Functions ¶
func GenerateDSN ¶
Types ¶
type DatabaseServer ¶
type DatabaseServer struct {
// contains filtered or unexported fields
}
func NewDatabaseServer ¶
func NewDatabaseServer(ctx context.Context, connString dbov1.PostgreSQLDSN) (*DatabaseServer, error)
func NewDatabaseServerWithMock ¶
func NewDatabaseServerWithMock( _ context.Context, connString dbov1.PostgreSQLDSN, conn databaseConnection, ) (*DatabaseServer, error)
func (*DatabaseServer) CopyInitConfigToSecret ¶
func (s *DatabaseServer) CopyInitConfigToSecret( dbAccount *dbov1.DatabaseAccount, secret *corev1.Secret, )
func (*DatabaseServer) CreateDatabase ¶
func (*DatabaseServer) CreateRole ¶
func (*DatabaseServer) CreateSchema ¶
func (s *DatabaseServer) CreateSchema(ctx context.Context, schemaName, roleName string) error
func (*DatabaseServer) Delete ¶
func (s *DatabaseServer) Delete(ctx context.Context, name string) error
func (*DatabaseServer) GetDatabaseHost ¶
func (s *DatabaseServer) GetDatabaseHost(dbAccount *dbov1.DatabaseAccount) string
func (*DatabaseServer) GetDatabaseHostConfig ¶
func (s *DatabaseServer) GetDatabaseHostConfig() string
func (*DatabaseServer) IsDatabase ¶
func (*DatabaseServer) UpdateRolePassword ¶
type Server ¶
type Server interface { Connect(ctx context.Context) error Close(ctx context.Context) error ListUsers(ctx context.Context) []string IsRole(ctx context.Context, roleName string) (bool, error) IsDatabase(ctx context.Context, dbName string) (string, bool, error) CreateRole(ctx context.Context, roleName string) (string, string, error) UpdateRolePassword(ctx context.Context, roleName string) (string, string, error) CreateDatabase(ctx context.Context, dbName, roleName string) (string, error) CreateSchema(ctx context.Context, schemaName, roleName string) error GetDatabaseHostConfig() string GetDatabaseHost(dbAccount *dbov1.DatabaseAccount) string CopyInitConfigToSecret(dbAccount *dbov1.DatabaseAccount, secret *corev1.Secret) Delete(ctx context.Context, name string) error }
Click to show internal directories.
Click to hide internal directories.