azuresqlmanageduser

package
v0.0.0-...-64c179a Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureSqlManagedUserManager

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

func NewAzureSqlManagedUserManager

func NewAzureSqlManagedUserManager(creds config.Credentials, secretClient secrets.SecretClient, scheme *runtime.Scheme) *AzureSqlManagedUserManager

func (*AzureSqlManagedUserManager) ConnectToSqlDbAsCurrentUser

func (s *AzureSqlManagedUserManager) ConnectToSqlDbAsCurrentUser(ctx context.Context, server string, database string) (db *sql.DB, err error)

ConnectToSqlDb connects to the SQL db using the current identity of operator (should be MI)

func (*AzureSqlManagedUserManager) Delete

Delete deletes a user

func (*AzureSqlManagedUserManager) DeleteSecrets

func (s *AzureSqlManagedUserManager) DeleteSecrets(ctx context.Context, instance *v1alpha1.AzureSQLManagedUser, secretClient secrets.SecretClient) error

DeleteSecret deletes a secret

func (*AzureSqlManagedUserManager) DropUser

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

DropUser drops a user from db

func (*AzureSqlManagedUserManager) EnableUser

func (s *AzureSqlManagedUserManager) EnableUser(ctx context.Context, MIName string, MIUserClientId string, db *sql.DB) error

EnableUser creates user with secret credentials

func (*AzureSqlManagedUserManager) Ensure

Ensure that user exists

func (*AzureSqlManagedUserManager) GetDB

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

GetDB retrieves a database

func (*AzureSqlManagedUserManager) GetParents

GetParents gets the parents of the user

func (*AzureSqlManagedUserManager) GetStatus

GetStatus gets the status

func (*AzureSqlManagedUserManager) GrantUserRoles

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

GrantUserRoles grants roles to a user for a given database

func (*AzureSqlManagedUserManager) UpdateSecret

func (s *AzureSqlManagedUserManager) UpdateSecret(ctx context.Context, instance *v1alpha1.AzureSQLManagedUser, secretClient secrets.SecretClient) error

UpdateSecret gets or creates a secret

func (*AzureSqlManagedUserManager) UserExists

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

UserExists checks if db contains user

type SqlManagedUserManager

type SqlManagedUserManager interface {
	GetDB(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (azuresql.Database, error)
	ConnectToSqlDbAsCurrentUser(ctx context.Context, drivername string, server string, dbname string) (*sql.DB, error)

	DeleteSecrets(ctx context.Context, instance *v1alpha1.AzureSQLManagedUser, secretClient secrets.SecretClient) error
	UpdateSecret(ctx context.Context, instance *v1alpha1.AzureSQLManagedUser, secretClient secrets.SecretClient) error

	EnableUser(ctx context.Context, MIName string, MIUserClientId string, db *sql.DB) error
	GrantUserRoles(ctx context.Context, user string, roles []string, db *sql.DB) error
	DropUser(ctx context.Context, db *sql.DB, user string) error
	UserExists(ctx context.Context, db *sql.DB, username string) (bool, error)
	// 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