Documentation ¶
Index ¶
- Constants
- func GetDatabaseRoles(ctx context.Context, db Database) map[DatabaseRoleId]DatabaseRole
- func GetDatabases(ctx context.Context, conn Connection) map[DatabaseId]Database
- func GetSchemas(ctx context.Context, db Database) map[SchemaId]Schema
- 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 AADObjectId
- type Connection
- type ConnectionAuth
- type ConnectionAuthAzure
- type ConnectionAuthSql
- type ConnectionDetails
- type Database
- type DatabaseId
- type DatabasePermission
- type DatabasePermissions
- type DatabasePrincipalId
- type DatabasePrincipalType
- type DatabaseRole
- type DatabaseRoleId
- type DatabaseRoleMember
- type DatabaseSettings
- type GenericDatabasePrincipalId
- type GenericServerPrincipalId
- type LoginId
- type NumericObjectId
- type ObjectId
- type Schema
- type SchemaId
- type SchemaPermission
- type SchemaPermissions
- type ServerPermission
- type ServerPermissions
- type ServerPrincipalType
- type ServerRole
- type ServerRoleId
- type ServerRoleMember
- type ServerRoleMembers
- type ServerRoleSettings
- type ServerRoles
- type SqlLogin
- type SqlLoginId
- type SqlLoginSettings
- type StringObjectId
- type User
- type UserId
- type UserSettings
- type UserType
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 GetSchemas ¶ added in v0.4.0
func GetSqlLogins ¶
func GetSqlLogins(ctx context.Context, conn Connection) map[LoginId]SqlLogin
Types ¶
type AADObjectId ¶ added in v0.2.0
type AADObjectId string
type Connection ¶
type Connection interface { IsAzure(context.Context) bool GetPermissions(ctx context.Context, principalId GenericServerPrincipalId) ServerPermissions GrantPermission(ctx context.Context, principalId GenericServerPrincipalId, permission ServerPermission) RevokePermission(ctx context.Context, principalId GenericServerPrincipalId, permission string) // contains filtered or unexported methods }
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) Query(ctx context.Context, query string) []map[string]string Exec(ctx context.Context, script string) GetPermissions(ctx context.Context, id GenericDatabasePrincipalId) DatabasePermissions GrantPermission(ctx context.Context, id GenericDatabasePrincipalId, permission DatabasePermission) UpdatePermission(ctx context.Context, id GenericDatabasePrincipalId, permission DatabasePermission) RevokePermission(ctx context.Context, id GenericDatabasePrincipalId, permissionName string) // 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 DatabasePermission ¶ added in v0.5.0
type DatabasePermissions ¶ added in v0.5.0
type DatabasePermissions map[string]DatabasePermission
type DatabasePrincipalId ¶
type DatabasePrincipalId interface { UserId | DatabaseRoleId | GenericDatabasePrincipalId }
type DatabasePrincipalType ¶
type DatabasePrincipalType int
const ( UNONOWN DatabasePrincipalType = iota SQL_USER DATABASE_ROLE AZUREAD_USER )
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 GenericServerPrincipalId ¶ added in v0.6.0
type GenericServerPrincipalId int
const EmptyServerPrincipalId GenericServerPrincipalId = -1
type NumericObjectId ¶
type NumericObjectId interface { DatabaseId | DatabasePrincipalId | SchemaId | GenericServerPrincipalId }
type ObjectId ¶
type ObjectId interface { NumericObjectId | StringObjectId }
type Schema ¶ added in v0.4.0
type Schema interface { GetDb(context.Context) Database GetId(context.Context) SchemaId GetName(context.Context) string GetOwnerId(context.Context) GenericDatabasePrincipalId ChangeOwner(_ context.Context, ownerId GenericDatabasePrincipalId) Drop(context.Context) GetPermissions(ctx context.Context, id GenericDatabasePrincipalId) SchemaPermissions GrantPermission(ctx context.Context, id GenericDatabasePrincipalId, permission SchemaPermission) UpdatePermission(ctx context.Context, id GenericDatabasePrincipalId, permission SchemaPermission) RevokePermission(ctx context.Context, id GenericDatabasePrincipalId, permission string) }
func CreateSchema ¶ added in v0.4.0
type SchemaPermission ¶ added in v0.5.0
type SchemaPermissions ¶ added in v0.5.0
type SchemaPermissions map[string]SchemaPermission
type ServerPermission ¶ added in v0.6.0
type ServerPermissions ¶ added in v0.6.0
type ServerPermissions map[string]ServerPermission
type ServerPrincipalType ¶ added in v0.6.0
type ServerPrincipalType int
const ( UNKNOWN ServerPrincipalType = iota SQL_LOGIN SERVER_ROLE )
type ServerRole ¶ added in v0.6.0
type ServerRole interface { GetId(ctx context.Context) ServerRoleId GetSettings(ctx context.Context) ServerRoleSettings Rename(ctx context.Context, name string) Drop(ctx context.Context) HasMember(ctx context.Context, id GenericServerPrincipalId) bool AddMember(ctx context.Context, id GenericServerPrincipalId) RemoveMember(ctx context.Context, id GenericServerPrincipalId) GetMembers(ctx context.Context) ServerRoleMembers }
func CreateServerRole ¶ added in v0.6.0
func CreateServerRole(ctx context.Context, conn Connection, settings ServerRoleSettings) ServerRole
func GetServerRole ¶ added in v0.6.0
func GetServerRole(_ context.Context, conn Connection, id ServerRoleId) ServerRole
func GetServerRoleByName ¶ added in v0.6.0
func GetServerRoleByName(ctx context.Context, conn Connection, name string) ServerRole
type ServerRoleId ¶ added in v0.6.0
type ServerRoleId GenericServerPrincipalId
type ServerRoleMember ¶ added in v0.6.0
type ServerRoleMember struct { Id GenericServerPrincipalId Name string Type ServerPrincipalType }
type ServerRoleMembers ¶ added in v0.6.0
type ServerRoleMembers map[GenericServerPrincipalId]ServerRoleMember
type ServerRoleSettings ¶ added in v0.6.0
type ServerRoleSettings struct { Name string OwnerId GenericServerPrincipalId }
type ServerRoles ¶ added in v0.6.0
type ServerRoles map[ServerRoleId]ServerRole
func GetServerRoles ¶ added in v0.6.0
func GetServerRoles(ctx context.Context, conn Connection) ServerRoles
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 SqlLoginId ¶ added in v0.6.0
type SqlLoginId GenericServerPrincipalId
type SqlLoginSettings ¶
type SqlLoginSettings struct { Name string Password string MustChangePassword bool DefaultDatabaseId DatabaseId DefaultLanguage string CheckPasswordExpiration bool CheckPasswordPolicy bool PrincipalId SqlLoginId }
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 ¶
type UserSettings struct { Name string LoginId LoginId AADObjectId AADObjectId Type UserType }
Click to show internal directories.
Click to hide internal directories.