Documentation ¶
Index ¶
- Constants
- func GetDatabaseRoles(ctx context.Context, db Database) map[DatabaseRoleId]DatabaseRole
- func GetDatabases(ctx context.Context, conn Connection) map[DatabaseId]Database
- func GetSqlLogins(ctx context.Context, conn Connection) map[LoginId]SqlLogin
- func GetUsers(ctx context.Context, db Database) map[UserId]User
- func WithConnection[T any](ctx context.Context, connectionFactory func(context.Context) *sql.DB, ...) T
- type Connection
- type ConnectionAuth
- type ConnectionAuthAzure
- type ConnectionAuthSql
- type ConnectionDetails
- type Database
- type DatabaseId
- type DatabasePrincipalId
- type DatabasePrincipalType
- type DatabaseRole
- type DatabaseRoleId
- type DatabaseRoleMember
- type DatabaseSettings
- type GenericDatabasePrincipalId
- type LoginId
- type NumericObjectId
- type ObjectId
- type SqlLogin
- type SqlLoginSettings
- type StringObjectId
- type User
- type UserId
- type UserSettings
Constants ¶
View Source
const NullDatabaseId = DatabaseId(-1)
Variables ¶
This section is empty.
Functions ¶
func GetDatabaseRoles ¶
func GetDatabaseRoles(ctx context.Context, db Database) map[DatabaseRoleId]DatabaseRole
func GetDatabases ¶
func GetDatabases(ctx context.Context, conn Connection) map[DatabaseId]Database
func GetSqlLogins ¶
func GetSqlLogins(ctx context.Context, conn Connection) map[LoginId]SqlLogin
Types ¶
type Connection ¶
type ConnectionAuth ¶
type ConnectionAuth interface {
// contains filtered or unexported methods
}
type ConnectionAuthAzure ¶
type ConnectionAuthSql ¶
type ConnectionDetails ¶
type ConnectionDetails struct { Host string Database string Auth ConnectionAuth }
func (ConnectionDetails) Open ¶
func (cd ConnectionDetails) Open(ctx context.Context) (Connection, diag.Diagnostics)
type Database ¶
type Database interface { GetConnection(context.Context) Connection GetId(context.Context) DatabaseId Exists(context.Context) bool GetSettings(context.Context) DatabaseSettings Rename(_ context.Context, name string) SetCollation(_ context.Context, collation string) Drop(context.Context) // contains filtered or unexported methods }
func CreateDatabase ¶
func CreateDatabase(ctx context.Context, conn Connection, settings DatabaseSettings) Database
func GetDatabase ¶
func GetDatabase(_ context.Context, conn Connection, id DatabaseId) Database
func GetDatabaseByName ¶
func GetDatabaseByName(ctx context.Context, conn Connection, name string) Database
type DatabaseId ¶
type DatabaseId int
type DatabasePrincipalId ¶
type DatabasePrincipalId interface { UserId | DatabaseRoleId | GenericDatabasePrincipalId }
type DatabasePrincipalType ¶
type DatabasePrincipalType int
const ( UNONOWN DatabasePrincipalType = iota SQL_USER DATABASE_ROLE )
type DatabaseRole ¶
type DatabaseRole interface { GetId(context.Context) DatabaseRoleId GetOwnerId(context.Context) GenericDatabasePrincipalId GetDb(context.Context) Database GetName(context.Context) string Drop(context.Context) Rename(_ context.Context, name string) ChangeOwner(_ context.Context, ownerId GenericDatabasePrincipalId) AddMember(_ context.Context, memberId GenericDatabasePrincipalId) HasMember(_ context.Context, memberId GenericDatabasePrincipalId) bool RemoveMember(_ context.Context, memberId GenericDatabasePrincipalId) GetMembers(_ context.Context) map[GenericDatabasePrincipalId]DatabaseRoleMember }
func CreateDatabaseRole ¶
func CreateDatabaseRole[T DatabasePrincipalId](ctx context.Context, db Database, name string, ownerId T) DatabaseRole
func GetDatabaseRole ¶
func GetDatabaseRole(_ context.Context, db Database, id DatabaseRoleId) DatabaseRole
func GetDatabaseRoleByName ¶
func GetDatabaseRoleByName(ctx context.Context, db Database, name string) DatabaseRole
type DatabaseRoleId ¶
type DatabaseRoleId GenericDatabasePrincipalId
type DatabaseRoleMember ¶
type DatabaseRoleMember struct { Id GenericDatabasePrincipalId Name string Type DatabasePrincipalType }
type DatabaseSettings ¶
type GenericDatabasePrincipalId ¶
type GenericDatabasePrincipalId int
const EmptyDatabasePrincipalId GenericDatabasePrincipalId = -1
type NumericObjectId ¶
type NumericObjectId interface { DatabaseId | DatabasePrincipalId }
type ObjectId ¶
type ObjectId interface { NumericObjectId | StringObjectId }
type SqlLogin ¶
type SqlLogin interface { GetId(context.Context) LoginId Exists(context.Context) bool GetSettings(context.Context) SqlLoginSettings UpdateSettings(ctx context.Context, settings SqlLoginSettings) Drop(ctx context.Context) // contains filtered or unexported methods }
func CreateSqlLogin ¶
func CreateSqlLogin(ctx context.Context, conn Connection, settings SqlLoginSettings) SqlLogin
func GetSqlLogin ¶
func GetSqlLogin(_ context.Context, conn Connection, id LoginId) SqlLogin
func GetSqlLoginByName ¶
func GetSqlLoginByName(ctx context.Context, conn Connection, name string) SqlLogin
type SqlLoginSettings ¶
type StringObjectId ¶
type StringObjectId interface { LoginId }
type User ¶
type User interface { GetId(context.Context) UserId GetDatabaseId(context.Context) DatabaseId GetSettings(context.Context) UserSettings Drop(context.Context) UpdateSettings(context.Context, UserSettings) }
func CreateUser ¶
func CreateUser(ctx context.Context, db Database, settings UserSettings) User
type UserId ¶
type UserId GenericDatabasePrincipalId
type UserSettings ¶
Click to show internal directories.
Click to hide internal directories.