psqluser

package
v0.0.0-...-6806e21 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const PDriverName = "postgres"

PDriverName is driver name for psqldb connection

View Source
const PSecretPasswordKey = "password"

PSecretPasswordKey is the password key in secret

View Source
const PSecretUsernameKey = "username"

PSecretUsernameKey is the username key in secret

View Source
const PSqlServerPort = 5432

PSqlServerPort is the default server port for sql server

Variables

This section is empty.

Functions

This section is empty.

Types

type PSqlUserManager

type PSqlUserManager interface {
	GetDB(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (psql.Database, error)
	ConnectToPostgreSqlDb(ctx context.Context, drivername string, server string, dbname string, port int, username string, password string) (*sql.DB, error)
	GrantUserRoles(ctx context.Context, user string, roles []string, db *sql.DB) error
	CreateUser(ctx context.Context, secret map[string][]byte, db *sql.DB) (string, error)
	UserExists(ctx context.Context, db *sql.DB, username string) (bool, error)
	DropUser(ctx context.Context, db *sql.DB, user string) error
	DeleteSecrets(ctx context.Context, instance *v1alpha1.PostgreSQLUser, secretClient secrets.SecretClient) (bool, error)
	GetOrPrepareSecret(ctx context.Context, instance *v1alpha1.PostgreSQLUser, secretClient secrets.SecretClient) map[string][]byte

	// also embed methods from AsyncClient
	resourcemanager.ARMClient
}

type PostgreSqlUserManager

type PostgreSqlUserManager struct {
	Creds        config.Credentials
	SecretClient secrets.SecretClient
	Scheme       *runtime.Scheme
}

PostgreSqlUserManager for psqluser manager

func NewPostgreSqlUserManager

func NewPostgreSqlUserManager(creds config.Credentials, secretClient secrets.SecretClient, scheme *runtime.Scheme) *PostgreSqlUserManager

NewPostgreSqlUserManager creates a new PostgreSqlUserManager

func (*PostgreSqlUserManager) ConnectToSqlDb

func (m *PostgreSqlUserManager) ConnectToSqlDb(ctx context.Context, drivername string, fullservername string, database string, port int, user string, password string) (*sql.DB, error)

ConnectToSqlDb connects to the PostgreSQL db using the given credentials

func (*PostgreSqlUserManager) CreateUser

func (m *PostgreSqlUserManager) CreateUser(ctx context.Context, secret map[string][]byte, db *sql.DB) (string, error)

CreateUser creates user with secret credentials

func (*PostgreSqlUserManager) Delete

Delete deletes a user

func (*PostgreSqlUserManager) DeleteSecrets

func (m *PostgreSqlUserManager) DeleteSecrets(ctx context.Context, instance *v1alpha1.PostgreSQLUser, secretClient secrets.SecretClient) (bool, error)

DeleteSecrets deletes the secrets associated with a SQLUser

func (*PostgreSqlUserManager) DropUser

func (m *PostgreSqlUserManager) DropUser(ctx context.Context, db *sql.DB, user string) error

DropUser drops a user from db

func (*PostgreSqlUserManager) Ensure

Ensure that user exists

func (*PostgreSqlUserManager) GetDB

func (m *PostgreSqlUserManager) GetDB(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (db psql.Database, err error)

GetDB retrieves a database

func (*PostgreSqlUserManager) GetOrPrepareSecret

func (m *PostgreSqlUserManager) GetOrPrepareSecret(ctx context.Context, instance *v1alpha1.PostgreSQLUser, secretClient secrets.SecretClient) map[string][]byte

GetOrPrepareSecret gets or creates a secret

func (*PostgreSqlUserManager) GetParents

GetParents gets the parents of the user

func (*PostgreSqlUserManager) GetStatus

GetStatus gets the status

func (*PostgreSqlUserManager) GrantUserRoles

func (m *PostgreSqlUserManager) GrantUserRoles(ctx context.Context, user string, roles []string, db *sql.DB) error

GrantUserRoles grants roles to a user for a given database

func (*PostgreSqlUserManager) UpdateUser

func (m *PostgreSqlUserManager) UpdateUser(ctx context.Context, secret map[string][]byte, db *sql.DB) error

UpdateUser - Updates user password

func (*PostgreSqlUserManager) UserExists

func (m *PostgreSqlUserManager) UserExists(ctx context.Context, db *sql.DB, username string) (bool, error)

UserExists checks if db contains user

Jump to

Keyboard shortcuts

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