Documentation
¶
Overview ¶
Package common provides common libraries for the service.
Index ¶
- Constants
- Variables
- func BackupDatabaseNameOfEngine(e storepb.Engine) string
- func ConvertANTLRLineToPosition(line int) *storepb.Position
- func ConvertANTLRPositionToPosition(a *ANTLRPosition, text string) *storepb.Position
- func ConvertPGParserErrorCursorPosToPosition(cursorPos int, text string) *storepb.Position
- func ConvertTiDBParserErrorPositionToPosition(line, column int) *storepb.Position
- func ConvertToParserEngine(e storepb.Engine) (storepb.Engine, error)
- func ConvertUnparsedApproval(expression *expr.Expr) (*exprproto.ParsedExpr, error)
- func EngineSupportAutoComplete(e storepb.Engine) bool
- func EngineSupportCreateDatabase(e storepb.Engine) bool
- func EngineSupportMasking(e storepb.Engine) bool
- func EngineSupportPriorBackup(e storepb.Engine) bool
- func EngineSupportQueryNewACL(engine storepb.Engine) bool
- func EngineSupportQuerySpanPlainField(e storepb.Engine) bool
- func EngineSupportSQLReview(engine storepb.Engine) bool
- func EngineSupportStatementAdvise(e storepb.Engine) bool
- func EngineSupportStatementReport(e storepb.Engine) bool
- func EngineSupportSyntaxCheck(e storepb.Engine) bool
- func EvalBindingCondition(expr string, requestTime time.Time) (bool, error)
- func FormatChangelog(instanceID, databaseID string, changelogUID int64) string
- func FormatDBErrorEmptyRowWithQuery(query string) error
- func FormatDatabase(instance string, database string) string
- func FormatEnvironment(resourceID string) string
- func FormatGroupEmail(email string) string
- func FormatInstance(resourceID string) string
- func FormatIssue(projectID string, issueUID int) string
- func FormatMaximumSQLResultSizeMessage(limit int64) string
- func FormatPlan(projectID string, planUID int64) string
- func FormatPlanCheckRun(projectID string, planUID, runUID int64) string
- func FormatProject(id string) string
- func FormatReleaseFile(release string, fileID string) string
- func FormatReleaseName(projectID string, releaseUID int64) string
- func FormatReviewConfig(id string) string
- func FormatRevision(instanceID, databaseID string, revisionUID int64) string
- func FormatRole(role string) string
- func FormatRollout(projectID string, pipelineUID int) string
- func FormatSheet(projectID string, sheetUID int) string
- func FormatStage(projectID string, pipelineUID int, stageID string) string
- func FormatStageID(environment string) string
- func FormatTask(projectID string, pipelineUID int, stageID string, taskUID int) string
- func FormatTaskRun(projectID string, pipelineUID int, stageID string, taskUID, taskRunUID int) string
- func FormatUserEmail(email string) string
- func FormatUserUID(uid int) string
- func FormatWorkspace(id string) string
- func GetEnvironmentID(name string) (string, error)
- func GetGroupEmail(name string) (string, error)
- func GetIdentityProviderID(name string) (string, error)
- func GetInstanceDatabaseChangelogUID(name string) (string, string, int64, error)
- func GetInstanceDatabaseID(name string) (string, string, error)
- func GetInstanceDatabaseRevisionID(name string) (string, string, int64, error)
- func GetInstanceID(name string) (string, error)
- func GetIssueID(name string) (int, error)
- func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error)
- func GetPolicyResourceTypeAndResource(requestName string) (storepb.Policy_Resource, *string, error)
- func GetPostgresSocketDir() string
- func GetProjectID(name string) (string, error)
- func GetProjectIDDatabaseGroupID(name string) (string, string, error)
- func GetProjectIDIssueUID(name string) (string, int, error)
- func GetProjectIDIssueUIDIssueCommentUID(name string) (string, int, int, error)
- func GetProjectIDPlanID(name string) (string, int64, error)
- func GetProjectIDPlanIDPlanCheckRunID(name string) (string, int, int, error)
- func GetProjectIDRolloutID(name string) (string, int, error)
- func GetProjectIDRolloutIDMaybeStageID(name string) (string, int, *string, error)
- func GetProjectIDRolloutIDMaybeStageIDMaybeTaskID(name string) (string, int, *string, *int, error)
- func GetProjectIDRolloutIDStageIDMaybeTaskID(name string) (string, int, string, *int, error)
- func GetProjectIDRolloutIDStageIDTaskID(name string) (string, int, string, int, error)
- func GetProjectIDRolloutIDStageIDTaskIDTaskRunID(name string) (string, int, string, int, int, error)
- func GetProjectIDWebhookID(name string) (string, string, error)
- func GetProjectReleaseUID(name string) (string, int64, error)
- func GetProjectReleaseUIDFile(name string) (string, int64, string, error)
- func GetProjectResourceIDSheetUID(name string) (string, int, error)
- func GetReviewConfigID(name string) (string, error)
- func GetRiskLevelFromStatementTypes(statementTypes []string) storepb.RiskLevel
- func GetRoleID(name string) (string, error)
- func GetSchemaTableName(name string) (string, string, error)
- func GetSetServiceDataFromContext(ctx context.Context) (func(a *anypb.Any), bool)
- func GetSettingName(name string) (string, error)
- func GetUIDFromName(name, prefix string) (int, error)
- func GetUserEmail(name string) (string, error)
- func GetUserID(name string) (int, error)
- func GetWorksheetUID(name string) (int, error)
- func HasPrefixes(src string, prefixes ...string) bool
- func IsDev() bool
- func IsNil(val any) bool
- func IsNonTransactionStatement(stmt string) bool
- func IsSpaceOrSemicolon(r rune) bool
- func NewP[T any](x T) *T
- func NormalizeExternalURL(url string) (string, error)
- func Obfuscate(src, seed string) string
- func RandomString(n int) (string, error)
- func Retry(ctx context.Context, fn func() error) error
- func SanitizeUTF8String(s string) string
- func TrimStatement(statement string) string
- func TrimSuffix(name, suffix string) (string, error)
- func TrimSuffixAndGetInstanceDatabaseID(name string, suffix string) (string, string, error)
- func TruncateString(str string, limit int) (string, bool)
- func TruncateStringWithDescription(str string) string
- func Unobfuscate(dst, seed string) (string, error)
- func ValidateGroupCELExpr(expr string) (cel.Program, error)
- func ValidateMaskingExceptionCELExpr(expression *expr.Expr) (cel.Program, error)
- func ValidateMaskingRuleCELExpr(expr string) (cel.Program, error)
- func ValidatePhone(phone string) error
- func ValidateProjectMemberCELExpr(expression *expr.Expr) (cel.Program, error)
- func WithSetServiceData(ctx context.Context, setServiceData func(a *anypb.Any)) context.Context
- type ANTLRPosition
- type AuthContext
- type AuthMethod
- type Code
- type ContextKey
- type Error
- type IsolationLevel
- type QueryExportFactors
- type ReleaseMode
- type Resource
- type TransactionConfig
- type TransactionMode
Constants ¶
const ( // CELAttributeResourceEnvironmentID is the environment ID of the resource. CELAttributeResourceEnvironmentID = "resource.environment_id" // CELAttributeResourceProjectID is the project ID of the resource. CELAttributeResourceProjectID = "resource.project_id" // CELAttributeResourceInstanceID is the instance ID of the resource. CELAttributeResourceInstanceID = "resource.instance_id" // CELAttributeResourceDatabaseName is the database name of the resource. CELAttributeResourceDatabaseName = "resource.database_name" // CELAttributeResourceSchemaName is the schema name of the resource. CELAttributeResourceSchemaName = "resource.schema_name" // CELAttributeResourceTableName is the table name of the resource. CELAttributeResourceTableName = "resource.table_name" // CELAttributeResourceColumnName is the column name of the resource. CELAttributeResourceColumnName = "resource.column_name" // CELAttributeResourceDBEngine is the database engine of the resource. CELAttributeResourceDBEngine = "resource.db_engine" // CELAttributeResourceDatabase is the full database name of the resource (used in IAM policy conditions). CELAttributeResourceDatabase = "resource.database" // CELAttributeResourceClassificationLevel is the classification level of the resource. CELAttributeResourceClassificationLevel = "resource.classification_level" // CELAttributeResourceDatabaseLabels is the database labels of the resource. CELAttributeResourceDatabaseLabels = "resource.database_labels" )
CEL attribute names for resource scope.
const ( // CELAttributeStatementAffectedRows is the number of affected rows by the statement. CELAttributeStatementAffectedRows = "statement.affected_rows" // CELAttributeStatementTableRows is the total number of rows in the table. CELAttributeStatementTableRows = "statement.table_rows" // CELAttributeStatementSQLType is the SQL statement type (e.g., SELECT, INSERT, UPDATE, DELETE). CELAttributeStatementSQLType = "statement.sql_type" // CELAttributeStatementText is the full text of the SQL statement. CELAttributeStatementText = "statement.text" )
CEL attribute names for statement scope.
const ( // CELAttributeRequestExpirationDays is the number of days until the request expires. CELAttributeRequestExpirationDays = "request.expiration_days" // CELAttributeRequestRole is the requested role. CELAttributeRequestRole = "request.role" // CELAttributeRequestTime is the timestamp of the request. CELAttributeRequestTime = "request.time" )
CEL attribute names for request scope.
const ( // CELAttributeLevel is the risk level (deprecated). CELAttributeLevel = "level" // CELAttributeSource is the risk source (deprecated). CELAttributeSource = "source" )
CEL attribute names for approval scope (deprecated, kept for backward compatibility).
const ( WorkspaceAdmin = "workspaceAdmin" WorkspaceMember = "workspaceMember" ProjectOwner = "projectOwner" )
const ( // SystemBotID is the ID of the system robot. SystemBotID = 1 // AllUsers is the email of the pseudo allUsers account. AllUsers = "allUsers" // PrincipalIDForFirstUser is the principal id for the first user in workspace. PrincipalIDForFirstUser = 101 // ServiceAccountAccessKeyPrefix is the prefix for service account access key. ServiceAccountAccessKeyPrefix = "bbs_" )
const ( // DefaultProjectID is the resource ID for the default project. DefaultProjectID = "default" // DefaultTestEnvironmentID is the initial resource ID for the test environment. // This can be mutated by the user. But for now this is only used by onboarding flow to create // a test instance after first signup, so it's safe to refer it. DefaultTestEnvironmentID = "test" // DefaultProdEnvironmentID is the initial resource ID for the prod environment. // This can be mutated by the user. But for now this is only used by onboarding flow to create // a prod instance after first signup, so it's safe to refer it. DefaultProdEnvironmentID = "prod" )
const ( WorkspacePrefix = "workspaces/" ProjectNamePrefix = "projects/" EnvironmentNamePrefix = "environments/" InstanceNamePrefix = "instances/" PolicyNamePrefix = "policies/" DatabaseIDPrefix = "databases/" InstanceRolePrefix = "roles/" UserNamePrefix = "users/" IdentityProviderNamePrefix = "idps/" SettingNamePrefix = "settings/" RolloutPrefix = "rollouts/" StagePrefix = "stages/" TaskPrefix = "tasks/" TaskRunPrefix = "taskRuns/" PlanPrefix = "plans/" PlanCheckRunPrefix = "planCheckRuns/" RolePrefix = "roles/" WebhookIDPrefix = "webhooks/" SheetIDPrefix = "sheets/" WorksheetIDPrefix = "worksheets/" DatabaseGroupNamePrefix = "databaseGroups/" SchemaNamePrefix = "schemas/" TableNamePrefix = "tables/" ChangelogPrefix = "changelogs/" IssueNamePrefix = "issues/" IssueCommentNamePrefix = "issueComments/" PipelineNamePrefix = "pipelines/" LogNamePrefix = "logs/" BranchPrefix = "branches/" DeploymentConfigPrefix = "deploymentConfigs/" AuditLogPrefix = "auditLogs/" GroupPrefix = "groups/" ReviewConfigPrefix = "reviewConfigs/" ReleaseNamePrefix = "releases/" FileNamePrefix = "files/" RevisionNamePrefix = "revisions/" SchemaSuffix = "/schema" SDLSchemaSuffix = "/sdlSchema" MetadataSuffix = "/metadata" CatalogSuffix = "/catalog" UserBindingPrefix = "user:" GroupBindingPrefix = "group:" )
nolint:revive
const ( // MaxSheetSize is the maximum size (2M) of a sheet for displaying. MaxSheetSize = 2 * 1024 * 1024 // MaxSheetCheckSize is the maximum size of a sheet for checking changes. MaxSheetCheckSize = 2 * 1024 * 1024 // The maximum number of bytes for sql results in response body. // 100 MB. DefaultMaximumSQLResultSize = int64(100 * 1024 * 1024) // MaximumCommands is the maximum number of commands that can be executed in a single transaction. MaximumCommands = 200 // MaximumAdvicePerStatus is the maximum number of advice that can be returned per status. MaximumAdvicePerStatus = 50 MaximumLintExplainSize = 10 // MinimumCompletedPlanCheckRun is the minimum number required to generate approval flow. MinimumCompletedPlanCheckRun = 5 // ExternalURLPlaceholder is the docs link to configure --external-url. ExternalURLPlaceholder = "https://docs.bytebase.com/get-started/self-host/external-url" )
const DefaultInstanceMaximumConnections = 10
DefaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.
const EmptyStageID = "-"
EmptyStageID is the placeholder used for stages without environment or with deleted environments.
const ( // ReservedTagReviewConfig is the tag for review config. ReservedTagReviewConfig string = "bb.tag.review_config" )
Variables ¶
var ApprovalFactors = []cel.EnvOption{ cel.Variable(CELAttributeResourceEnvironmentID, cel.StringType), cel.Variable(CELAttributeResourceProjectID, cel.StringType), cel.Variable(CELAttributeResourceInstanceID, cel.StringType), cel.Variable(CELAttributeResourceDBEngine, cel.StringType), cel.Variable(CELAttributeResourceDatabaseName, cel.StringType), cel.Variable(CELAttributeResourceSchemaName, cel.StringType), cel.Variable(CELAttributeResourceTableName, cel.StringType), cel.Variable(CELAttributeStatementAffectedRows, cel.IntType), cel.Variable(CELAttributeStatementTableRows, cel.IntType), cel.Variable(CELAttributeStatementSQLType, cel.StringType), cel.Variable(CELAttributeStatementText, cel.StringType), cel.Variable(CELAttributeRequestExpirationDays, cel.IntType), cel.Variable(CELAttributeRequestRole, cel.StringType), cel.ParserExpressionSizeLimit(celLimit), }
ApprovalFactors are the variables when finding the approval template. After the risk layer removal (3.13), approval rules use the same variables as risk evaluation.
var DatabaseGroupCELAttributes = []cel.EnvOption{ cel.Variable(CELAttributeResourceEnvironmentID, cel.StringType), cel.Variable(CELAttributeResourceInstanceID, cel.StringType), cel.Variable(CELAttributeResourceDatabaseName, cel.StringType), cel.Variable(CELAttributeResourceDatabaseLabels, cel.MapType(cel.StringType, cel.StringType)), cel.ParserExpressionSizeLimit(celLimit), }
DatabaseGroupCELAttributes are the variables when evaluating database group conditions.
var IAMPolicyConditionCELAttributes = []cel.EnvOption{ cel.Variable(CELAttributeResourceEnvironmentID, cel.StringType), cel.Variable(CELAttributeResourceDatabase, cel.StringType), cel.Variable(CELAttributeResourceSchemaName, cel.StringType), cel.Variable(CELAttributeResourceTableName, cel.StringType), cel.Variable(CELAttributeRequestTime, cel.TimestampType), cel.ParserExpressionSizeLimit(celLimit), }
IAMPolicyConditionCELAttributes are the variables when evaluating IAM policy condition.
var MaskingExceptionPolicyCELAttributes = []cel.EnvOption{ cel.Variable(CELAttributeResourceInstanceID, cel.StringType), cel.Variable(CELAttributeResourceDatabaseName, cel.StringType), cel.Variable(CELAttributeResourceTableName, cel.StringType), cel.Variable(CELAttributeResourceSchemaName, cel.StringType), cel.Variable(CELAttributeResourceColumnName, cel.StringType), cel.Variable(CELAttributeRequestTime, cel.TimestampType), cel.ParserExpressionSizeLimit(celLimit), }
MaskingExceptionPolicyCELAttributes are the variables when evaluating masking exception.
var MaskingRulePolicyCELAttributes = []cel.EnvOption{ cel.Variable(CELAttributeResourceEnvironmentID, cel.StringType), cel.Variable(CELAttributeResourceProjectID, cel.StringType), cel.Variable(CELAttributeResourceInstanceID, cel.StringType), cel.Variable(CELAttributeResourceDatabaseName, cel.StringType), cel.Variable(CELAttributeResourceSchemaName, cel.StringType), cel.Variable(CELAttributeResourceTableName, cel.StringType), cel.Variable(CELAttributeResourceColumnName, cel.StringType), cel.Variable(CELAttributeResourceClassificationLevel, cel.StringType), cel.ParserExpressionSizeLimit(celLimit), }
MaskingRulePolicyCELAttributes are the variables when evaluating masking rule.
var ProtojsonUnmarshaler = protojson.UnmarshalOptions{DiscardUnknown: true}
ProtojsonMarshaler is a global protojson marshaler with DiscardUnknown set to true.
Functions ¶
func ConvertANTLRPositionToPosition ¶
func ConvertANTLRPositionToPosition(a *ANTLRPosition, text string) *storepb.Position
ConvertANTLRPositionToPosition converts an ANTLRPosition to a Position in a given text. ANTLRPosition uses 1-based line and 0-based character column. Returns a Position with 1-based line and 1-based character column. Returns the end Position if the ANTLRPosition is out of the end of text, returns the previous Position if the ANTLRPosition is out of the end of a line.
func ConvertUnparsedApproval ¶
func ConvertUnparsedApproval(expression *expr.Expr) (*exprproto.ParsedExpr, error)
ConvertUnparsedApproval converts unparsed approval to parsed format.
func EngineSupportMasking ¶
func EngineSupportSQLReview ¶
func EvalBindingCondition ¶
func FormatChangelog ¶
func FormatDBErrorEmptyRowWithQuery ¶
FormatDBErrorEmptyRowWithQuery formats database error that query returns empty row.
func FormatDatabase ¶
func FormatEnvironment ¶
func FormatGroupEmail ¶
func FormatInstance ¶
func FormatIssue ¶
func FormatPlan ¶
func FormatPlanCheckRun ¶
func FormatProject ¶
func FormatReleaseFile ¶
func FormatReleaseName ¶
func FormatReviewConfig ¶
func FormatRevision ¶
func FormatRole ¶
func FormatRollout ¶
func FormatSheet ¶
func FormatStage ¶
stageID is task environmentID.
func FormatStageID ¶
FormatStageID returns the stage ID, using EmptyStageID placeholder if environment is empty.
func FormatTask ¶
stageID is task environmentID.
func FormatTaskRun ¶
func FormatTaskRun(projectID string, pipelineUID int, stageID string, taskUID, taskRunUID int) string
stageID is task environmentID.
func FormatUserEmail ¶
func FormatUserUID ¶
func FormatWorkspace ¶
func GetEnvironmentID ¶
GetEnvironmentID returns the environment ID from a resource name.
func GetGroupEmail ¶
GetGroupEmail returns the group email.
func GetIdentityProviderID ¶
GetIdentityProviderID returns the identity provider ID from a resource name.
func GetInstanceDatabaseChangelogUID ¶
GetInstanceDatabaseChangelogUID returns the instance ID, database ID, and changelog UID from a resource name.
func GetInstanceDatabaseID ¶
GetInstanceDatabaseID returns the instance ID and database ID from a resource name.
func GetInstanceDatabaseRevisionID ¶
GetInstanceDatabaseRevisionID returns the instance ID, database ID, and revision UID from a resource name.
func GetInstanceID ¶
GetInstanceID returns the instance ID from a resource name.
func GetIssueID ¶
GetIssueID returns the issue ID from a resource name.
func GetNameParentTokens ¶
GetNameParentTokens returns the tokens from a resource name.
func GetPolicyResourceTypeAndResource ¶
func GetPolicyResourceTypeAndResource(requestName string) (storepb.Policy_Resource, *string, error)
func GetPostgresSocketDir ¶
func GetPostgresSocketDir() string
GetPostgresSocketDir returns the postgres socket directory of Bytebase.
func GetProjectID ¶
GetProjectID returns the project ID from a resource name.
func GetProjectIDDatabaseGroupID ¶
GetProjectIDDatabaseGroupID returns the project ID and database group ID from a resource name.
func GetProjectIDIssueUID ¶
GetProjectIDIssueUID returns the project ID and issue UID from the issue name.
func GetProjectIDIssueUIDIssueCommentUID ¶
GetProjectIDIssueUIDIssueCommentUID returns the project ID, issue UID and issue comment UID from the issue comment name.
func GetProjectIDPlanID ¶
GetProjectIDPlanID returns the project ID and plan ID from a resource name.
func GetProjectIDPlanIDPlanCheckRunID ¶
GetProjectIDPlanIDPlanCheckRunID returns the project ID, plan ID and plan check run ID from a resource name.
func GetProjectIDRolloutID ¶
GetProjectIDRolloutID returns the project ID and rollout ID from a resource name.
func GetProjectIDRolloutIDMaybeStageID ¶
GetProjectIDRolloutIDMaybeStageID returns the project ID, rollout ID, and maybe stage ID from a resource name.
func GetProjectIDRolloutIDMaybeStageIDMaybeTaskID ¶
GetProjectIDRolloutIDMaybeStageIDMaybeTaskID returns the project ID, rollout ID, and maybe stage ID and maybe task ID from a resource name.
func GetProjectIDRolloutIDStageIDMaybeTaskID ¶
GetProjectIDRolloutIDStageIDMaybeTaskID returns the project ID, rollout ID, and maybe stage ID and maybe task ID from a resource name.
func GetProjectIDRolloutIDStageIDTaskID ¶
GetProjectIDRolloutIDStageIDTaskID returns the project ID, rollout ID, stage ID, and task ID from a resource name.
func GetProjectIDRolloutIDStageIDTaskIDTaskRunID ¶
func GetProjectIDRolloutIDStageIDTaskIDTaskRunID(name string) (string, int, string, int, int, error)
GetProjectIDRolloutIDStageIDTaskIDTaskRunID returns the project ID, rollout ID, stage ID, task ID and task run ID from a resource name.
func GetProjectIDWebhookID ¶
GetProjectIDWebhookID returns the project ID and webhook ID from a resource name.
func GetProjectResourceIDSheetUID ¶
GetProjectResourceIDSheetUID returns the project ID and sheet UID from a resource name.
func GetReviewConfigID ¶
GetReviewConfigID returns the review config id from a resource name.
func GetRiskLevelFromStatementTypes ¶
GetRiskLevelFromStatementTypes returns the highest risk level for the given statement types.
func GetSchemaTableName ¶
GetSchemaTableName returns the schema and table names from a resource name.
func GetSettingName ¶
GetSettingName returns the setting name from a resource name.
func GetUIDFromName ¶
GetUIDFromName returns the UID from a resource name.
func GetUserEmail ¶
GetUserEmail returns the user email from a resource name.
func GetWorksheetUID ¶
GetWorksheetUID returns the worksheet UID from a resource name.
func HasPrefixes ¶
HasPrefixes returns true if the string s has any of the given prefixes.
func IsNonTransactionStatement ¶
IsNonTransactionStatement checks if a PostgreSQL statement cannot run inside a transaction block.
func IsSpaceOrSemicolon ¶
IsSpaceOrSemicolon checks if the rune is a space or a semicolon.
func NormalizeExternalURL ¶
NormalizeExternalURL will format the external url.
func RandomString ¶
RandomString returns a random string with length n.
func SanitizeUTF8String ¶
SanitizeUTF8String returns a copy of the string s with each run of invalid or unprintable UTF-8 byte sequences replaced by its hexadecimal representation string.
func TrimStatement ¶
TrimStatement trims the unused characters from the statement.
func TrimSuffix ¶
TrimSuffix trims the suffix from the name and returns the trimmed name.
func TrimSuffixAndGetInstanceDatabaseID ¶
TrimSuffixAndGetInstanceDatabaseID trims the suffix from the name and returns the instance ID and database ID.
func TruncateString ¶
TruncateString truncates the string to have a maximum length of `limit` characters.
func TruncateStringWithDescription ¶
TruncateStringWithDescription tries to truncate the string and append "... (view details in Bytebase)" if truncated.
func Unobfuscate ¶
Unobfuscate unobfuscates a string with a seed string.
func ValidateGroupCELExpr ¶
ValidateGroupCELExpr validates group expr.
func ValidateMaskingExceptionCELExpr ¶
ValidateMaskingExceptionCELExpr validates masking exception expr.
func ValidateMaskingRuleCELExpr ¶
ValidateMaskingRuleCELExpr validates masking rule expr.
func ValidatePhone ¶
ValidatePhone validates the phone number.
Types ¶
type ANTLRPosition ¶
type ANTLRPosition struct {
// Line position in a text (one-based).
Line int32
// Column position in a text (zero-based), equivalent to character offset.
Column int32
}
ANTLRPosition is a position in a text expressed as one-based line and zero-based column character (code point) offset integrated with ANTLR4.
type AuthContext ¶
type AuthContext struct {
Audit bool
AllowWithoutCredential bool
Permission string
AuthMethod AuthMethod
Resources []*Resource
}
func GetAuthContextFromContext ¶
func GetAuthContextFromContext(ctx context.Context) (*AuthContext, bool)
func (*AuthContext) GetProjectResources ¶
func (c *AuthContext) GetProjectResources() []string
func (*AuthContext) HasWorkspaceResource ¶
func (c *AuthContext) HasWorkspaceResource() bool
type AuthMethod ¶
type AuthMethod int
const ( AuthMethodUnspecified AuthMethod = iota AuthMethodIAM AuthMethodCustom )
type Code ¶
type Code int
Code is the error code.
const ( // 0 ~ 99 general error. Ok Code = 0 Internal Code = 1 NotAuthorized Code = 2 Invalid Code = 3 NotFound Code = 4 Conflict Code = 5 NotImplemented Code = 6 SizeExceeded Code = 7 // 101 ~ 199 db error. DBConnectionFailure Code = 101 DBExecutionError Code = 102 // 201 db migration error // Db migration is a core feature, so we separate it from the db error. MigrationSchemaMissing Code = 201 MigrationAlreadyApplied Code = 202 MigrationOutOfOrder Code = 203 // MigrationBaselineMissing is no longer used. // MigrationBaselineMissing Code = 204. MigrationPending Code = 205 MigrationFailed Code = 206 // 301 task error. TaskTimingNotAllowed Code = 301 // 401 task sql type error. TaskTypeNotDML Code = 401 TaskTypeNotDDL Code = 402 TaskTypeDropDatabase Code = 403 TaskTypeCreateDatabase Code = 404 TaskTypeDropTable Code = 405 TaskTypeDropIndex Code = 406 TaskTypeDropColumn Code = 407 TaskTypeDropPrimaryKey Code = 408 TaskTypeDropForeignKey Code = 409 TaskTypeDropCheck Code = 410 )
Application error codes.
type ContextKey ¶
type ContextKey int
ContextKey is the key type of context value.
const ( // UserContextKey is the key name used to store user message in the context. UserContextKey ContextKey = iota AuthContextKey ServiceDataKey )
type Error ¶
Error represents an application-specific error. Application errors can be unwrapped by the caller to extract out the code & message.
Any non-application error (such as a disk error) should be reported as an Internal error and the human user should only see "Internal error" as the message. These low-level internal error details should only be logged and reported to the operator of the application (not the end user).
type IsolationLevel ¶
type IsolationLevel string
IsolationLevel represents the transaction isolation level.
const ( // IsolationLevelDefault uses the database's default isolation level. IsolationLevelDefault IsolationLevel = "" // IsolationLevelReadUncommitted allows dirty reads. IsolationLevelReadUncommitted IsolationLevel = "READ UNCOMMITTED" // IsolationLevelReadCommitted prevents dirty reads. IsolationLevelReadCommitted IsolationLevel = "READ COMMITTED" // IsolationLevelRepeatableRead prevents dirty reads and non-repeatable reads. IsolationLevelRepeatableRead IsolationLevel = "REPEATABLE READ" // IsolationLevelSerializable provides the highest isolation level. IsolationLevelSerializable IsolationLevel = "SERIALIZABLE" )
type QueryExportFactors ¶
type QueryExportFactors struct {
Databases []string
}
QueryExportFactors is the factors for query and export.
func GetQueryExportFactors ¶
func GetQueryExportFactors(expression string) (*QueryExportFactors, error)
GetQueryExportFactors is used to get risk factors from query and export expressions.
type ReleaseMode ¶
type ReleaseMode string
ReleaseMode is the mode for release, such as dev or release.
const ( // ReleaseModeProd is the prod mode. ReleaseModeProd ReleaseMode = "prod" // ReleaseModeDev is the dev mode. ReleaseModeDev ReleaseMode = "dev" )
type TransactionConfig ¶
type TransactionConfig struct {
Mode TransactionMode
Isolation IsolationLevel
}
TransactionConfig represents the complete transaction configuration.
type TransactionMode ¶
type TransactionMode string
TransactionMode represents the transaction execution mode for a migration script.
const ( // TransactionModeOn wraps the script in a single transaction. TransactionModeOn TransactionMode = "on" // TransactionModeOff executes the script's statements sequentially in auto-commit mode. TransactionModeOff TransactionMode = "off" // TransactionModeUnspecified means no explicit mode was specified. TransactionModeUnspecified TransactionMode = "" )
func GetDefaultTransactionMode ¶
func GetDefaultTransactionMode() TransactionMode
GetDefaultTransactionMode returns the default transaction mode. All engines default to "on" (transactional) for safety and backward compatibility. Users can explicitly set "-- txn-mode = off" when needed for engines with limited transactional DDL support.