accountsvr

package
v0.0.0-...-9c6bfb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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

func GenerateDSN(secret *corev1.Secret) string

func GetSecretKV

func GetSecretKV(secret *corev1.Secret, key string) string

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) Close

func (s *DatabaseServer) Close(ctx context.Context) error

func (*DatabaseServer) Connect

func (s *DatabaseServer) Connect(ctx context.Context) error

func (*DatabaseServer) CopyInitConfigToSecret

func (s *DatabaseServer) CopyInitConfigToSecret(
	dbAccount *dbov1.DatabaseAccount,
	secret *corev1.Secret,
)

func (*DatabaseServer) CreateDatabase

func (s *DatabaseServer) CreateDatabase(ctx context.Context, dbName, roleName string) (string, error)

func (*DatabaseServer) CreateRole

func (s *DatabaseServer) CreateRole(ctx context.Context, roleName string) (string, string, error)

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 (s *DatabaseServer) IsDatabase(ctx context.Context, dbName string) (string, bool, error)

func (*DatabaseServer) IsRole

func (s *DatabaseServer) IsRole(ctx context.Context, roleName string) (bool, error)

func (*DatabaseServer) ListUsers

func (s *DatabaseServer) ListUsers(ctx context.Context) []string

func (*DatabaseServer) UpdateRolePassword

func (s *DatabaseServer) UpdateRolePassword(ctx context.Context, roleName string) (string, string, error)

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL