azuresqluser

package
v0.0.0-...-d214ba0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DriverName = "sqlserver"

DriverName is driver name for db connection

View Source
const SecretPasswordKey = "password"

SecretPasswordKey is the password key in secret

View Source
const SecretUsernameKey = "username"

SecretUsernameKey is the username key in secret

View Source
const SqlServerPort = 1433

SqlServerPort is the default server port for sql server

Variables

This section is empty.

Functions

func GetAdminSecretKey

func GetAdminSecretKey(adminSecretName string, namespace string) secrets.SecretKey

func MakeSecretKey

func MakeSecretKey(secretClient secrets.SecretClient, instance *v1alpha1.AzureSQLUser) secrets.SecretKey

Types

type AzureSqlUserManager

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

func NewAzureSqlUserManager

func NewAzureSqlUserManager(creds config.Credentials, secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlUserManager

func (*AzureSqlUserManager) ConnectToSqlDb

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

ConnectToSqlDb connects to the SQL db using the given credentials

func (*AzureSqlUserManager) CreateUser

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

CreateUser creates user with secret credentials

func (*AzureSqlUserManager) Delete

Delete deletes a user

func (*AzureSqlUserManager) DeleteSecrets

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

DeleteSecrets deletes the secrets associated with a SQLUser

func (*AzureSqlUserManager) DropUser

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

DropUser drops a user from db

func (*AzureSqlUserManager) Ensure

Ensure that user exists

func (*AzureSqlUserManager) GetDB

func (m *AzureSqlUserManager) GetDB(ctx context.Context, subscriptionID string, resourceGroupName string, serverName string, databaseName string) (azuresql.Database, error)

GetDB retrieves a database

func (*AzureSqlUserManager) GetOrPrepareSecret

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

GetOrPrepareSecret gets or creates a secret

func (*AzureSqlUserManager) GetParents

GetParents gets the parents of the user

func (*AzureSqlUserManager) GetStatus

func (s *AzureSqlUserManager) GetStatus(obj runtime.Object) (*v1alpha1.ASOStatus, error)

GetStatus gets the status

func (*AzureSqlUserManager) GrantUserRoles

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

GrantUserRoles grants roles to a user for a given database

func (*AzureSqlUserManager) UpdateUser

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

UpdateUser - Updates user password

func (*AzureSqlUserManager) UserExists

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

UserExists checks if db contains user

type SqlUserManager

type SqlUserManager interface {
	GetDB(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (azuresql.Database, error)
	ConnectToSqlDb(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.AzureSQLUser, secretClient secrets.SecretClient) (bool, error)
	GetOrPrepareSecret(ctx context.Context, instance *v1alpha1.AzureSQLUser, secretClient secrets.SecretClient) map[string][]byte

	// also embed methods from AsyncClient
	resourcemanager.ARMClient
}

Jump to

Keyboard shortcuts

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