Documentation
¶
Overview ¶
Package common provides common libraries for the service.
Index ¶
- Constants
- Variables
- func BuildMetaGUID(parts ...string) string
- func EscapeGUIDPart(part string) string
- func EvalBindingCondition(expr string, requestTime time.Time) (bool, error)
- func FormatAPIKey(id int64) string
- func FormatApplication(applicationID string) string
- func FormatApplicationAPIKey(applicationID string, keyID int64) string
- func FormatDBErrorEmptyRowWithQuery(query string) error
- func FormatDataSource(instanceID, dataSourceID string) string
- func FormatDatabase(instance string, database string) string
- func FormatEnvironment(resourceID string) string
- func FormatGroupEmail(email string) string
- func FormatIdentityProviderUID(idpID string) string
- func FormatInstance(resourceID string) string
- func FormatNamespaceMapping(id int64) string
- func FormatNotification(workspaceID string, id int64) string
- func FormatOpenLineageRun(guid string) string
- func FormatOpenLineageTask(guid string) string
- func FormatRole(role string) string
- func FormatUserUID(uid int) string
- func FormatWorkspace(id string) string
- func GUIDPrefix(guid string) string
- func GetAPIKeyID(name string) (int64, error)
- func GetApplicationAPIKeyID(name string) (string, int64, error)
- func GetApplicationID(name string) (string, error)
- func GetEnvironmentID(name string) (string, error)
- func GetGroupEmail(name string) (string, error)
- func GetIdentityProviderID(name string) (string, error)
- func GetInstanceDataSourceID(name string) (string, string, error)
- func GetInstanceDatabaseID(name string) (string, string, error)
- func GetInstanceFromGUID(guid string) (string, bool)
- func GetInstanceID(name string) (string, error)
- func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error)
- func GetNamespaceMappingID(name string) (int64, error)
- func GetNotificationID(name string) (int64, error)
- func GetOpenLineageIntID(name, prefix string) (int64, error)
- func GetOpenLineageRunGUID(name string) (string, error)
- func GetOpenLineageTaskGUID(name string) (string, error)
- func GetOpenLineageToken(name, prefix string) (string, error)
- func GetRoleID(name string) (string, error)
- func GetSchemaFromGUID(guid string) (string, bool)
- func GetUIDFromName(name, prefix string) (int, error)
- func GetUserEmail(name string) (string, error)
- func GetUserID(name string) (int, error)
- func IsValidResourceID(id string) bool
- func IsValidRoleID(id string) bool
- func RandomString(n int) (string, error)
- func SplitMetaGUID(guid string) []string
- func TruncateString(str string, limit int) (string, bool)
- func TruncateUTF8Bytes(str string, limit int) string
- func UnescapeGUIDPart(part string) string
- func ValidatePhone(phone string) error
- type AuthContext
- type Code
- type ContextKey
- type Error
- type ReleaseMode
Constants ¶
const ( // CELAttributeResourceEnvironmentID is the environment ID of the resource. CELAttributeResourceEnvironmentID = "resource.environment_id" // CELAttributeResourceSchemaName is the schema name of the resource. CELAttributeResourceSchemaName = "resource.schema_name" // CELAttributeResourceTableName is the table name of the resource. CELAttributeResourceTableName = "resource.table_name" // CELAttributeResourceDatabase is the full database name of the resource (used in IAM policy conditions). CELAttributeResourceDatabase = "resource.database" // CELAttributeRequestTime is the timestamp of the request. CELAttributeRequestTime = "request.time" )
CEL attribute names used by IAM policy conditions.
const ( WorkspaceAdmin = "workspaceAdmin" WorkspaceMember = "workspaceMember" )
const ( // SystemBotID is the ID of the system robot. SystemBotID = 1 // AllUsers is the email of the pseudo allUsers account. AllUsers = "allUsers" // ServiceAccountAccessKeyPrefix is the prefix for service account access key. ServiceAccountAccessKeyPrefix = "sa_" )
const ( DefaultMetaSubLevelLimit = 21 // MetaGUIDSplit is the separator for GUID in meta queries. MetaGUIDSplit = ";" )
const ( WorkspacePrefix = "workspaces/" EnvironmentNamePrefix = "environments/" InstanceNamePrefix = "instances/" DatabaseIDPrefix = "databases/" UserNamePrefix = "users/" IdentityProviderNamePrefix = "idps/" RolePrefix = "roles/" GroupPrefix = "groups/" DataSourceIDPrefix = "dataSources/" NamespaceMappingPrefix = "openlineage/namespaceMappings/" OpenLineageRunPrefix = "openlineage/runs/" OpenLineageTaskPrefix = "openlineage/tasks/" APIKeyPrefix = "openlineage/apiKeys/" ApplicationNamePrefix = "applications/" NotificationPrefix = "notifications/" )
nolint:revive
const DefaultInstanceMaximumConnections = 10
DefaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.
Variables ¶
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 ProtojsonUnmarshaler = protojson.UnmarshalOptions{DiscardUnknown: true}
ProtojsonMarshaler is a global protojson marshaler with DiscardUnknown set to true.
Functions ¶
func BuildMetaGUID ¶
BuildMetaGUID joins segments into a meta GUID. Every builder must use it (and every parser SplitMetaGUID) so the escaping stays symmetric.
func EscapeGUIDPart ¶
EscapeGUIDPart escapes the GUID separator inside one segment, so a name that contains ";" cannot shift the fields a parser reads out of a GUID.
func EvalBindingCondition ¶
EvalBindingCondition reports whether the binding condition holds. A condition that cannot be decided from the bound variables is reported as an error rather than as satisfied: see doEvalBindingCondition.
func FormatAPIKey ¶
FormatAPIKey formats an API key resource name.
func FormatApplication ¶
FormatApplication formats an application resource name.
func FormatApplicationAPIKey ¶
FormatApplicationAPIKey formats a reporting key's resource name, which is nested under the application that owns it.
func FormatDBErrorEmptyRowWithQuery ¶
FormatDBErrorEmptyRowWithQuery formats database error that query returns empty row.
func FormatDataSource ¶
FormatDataSource formats a data source resource name.
func FormatDatabase ¶
func FormatEnvironment ¶
func FormatGroupEmail ¶
func FormatIdentityProviderUID ¶
FormatIdentityProviderUID returns the idps/{idp} resource name of an identity provider, the form the settings API and the login request name one in.
func FormatInstance ¶
func FormatNamespaceMapping ¶
FormatNamespaceMapping formats a namespace mapping resource name.
func FormatNotification ¶
FormatNotification formats a notification resource name.
func FormatOpenLineageRun ¶
FormatOpenLineageRun formats an OpenLineage run resource name.
func FormatOpenLineageTask ¶
FormatOpenLineageTask formats an OpenLineage task resource name.
func FormatRole ¶
func FormatUserUID ¶
func FormatWorkspace ¶
func GUIDPrefix ¶
GUIDPrefix returns the parent prefix of a GUID: the GUID without its last MetaGUIDSplit-separated segment. It returns "" when the GUID has no parent segment.
func GetAPIKeyID ¶
GetAPIKeyID returns the API key ID from its resource name.
func GetApplicationAPIKeyID ¶
GetApplicationAPIKeyID returns the application id and the numeric key id from a key's resource name.
func GetApplicationID ¶
GetApplicationID returns the application id from a resource name, for a report that names the credential's owner.
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 GetInstanceDataSourceID ¶
GetInstanceDataSourceID returns the instance and data source IDs from a data source resource name.
func GetInstanceDatabaseID ¶
GetInstanceDatabaseID returns the instance ID and database ID from a resource name.
func GetInstanceFromGUID ¶
func GetInstanceID ¶
GetInstanceID returns the instance ID from a resource name.
func GetNameParentTokens ¶
GetNameParentTokens returns the tokens from a resource name.
func GetNamespaceMappingID ¶
GetNamespaceMappingID returns the namespace mapping ID from its resource name.
func GetNotificationID ¶
GetNotificationID returns the notification ID from its resource name.
func GetOpenLineageIntID ¶
GetOpenLineageIntID returns the numeric resource ID of a top-level OpenLineage resource name.
func GetOpenLineageRunGUID ¶
GetOpenLineageRunGUID returns the run GUID from its resource name.
func GetOpenLineageTaskGUID ¶
GetOpenLineageTaskGUID returns the task GUID from its resource name.
func GetOpenLineageToken ¶
GetOpenLineageToken returns the last segment of an OpenLineage resource name.
func GetSchemaFromGUID ¶
func GetUIDFromName ¶
GetUIDFromName returns the UID from a resource name.
func GetUserEmail ¶
GetUserEmail returns the user email from a resource name.
func IsValidResourceID ¶
IsValidResourceID reports whether id is a syntactically valid resource ID.
func IsValidRoleID ¶
IsValidRoleID reports whether id is a syntactically valid role ID.
func RandomString ¶
RandomString returns a random string with length n.
func SplitMetaGUID ¶
SplitMetaGUID splits a meta GUID into its segments and restores the separator inside each one, so callers get the original names back.
func TruncateUTF8Bytes ¶
TruncateUTF8Bytes cuts a string to at most limit bytes without splitting a multi-byte rune. Cutting mid-rune yields invalid UTF-8, which protobuf and JSON encoders reject outright, so a bound that slices bytes naively can drop the very record it was added to protect.
func UnescapeGUIDPart ¶
UnescapeGUIDPart restores the separator escaped by EscapeGUIDPart.
func ValidatePhone ¶
ValidatePhone validates the phone number.
Types ¶
type AuthContext ¶
func GetAuthContextFromContext ¶
func GetAuthContextFromContext(ctx context.Context) (*AuthContext, bool)
type Code ¶
type Code int
Code is the error code.
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 // TokenRestrictionContextKey is the key name used to store the restriction // carried by the access token that authenticated the request. It is absent // for a full-access token. TokenRestrictionContextKey )
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 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" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package crypto encrypts the credentials the server keeps in its own database: the instance and data source credentials, and the LLM provider API keys.
|
Package crypto encrypts the credentials the server keeps in its own database: the instance and data source credentials, and the LLM provider API keys. |
|
Package permission defines the metaxisdata permission catalog.
|
Package permission defines the metaxisdata permission catalog. |
|
gen
command
Command gen regenerates permission_gen.go from permission.json.
|
Command gen regenerates permission_gen.go from permission.json. |
|
Package version carries the server binary build metadata.
|
Package version carries the server binary build metadata. |