regosql
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package regosql converts rego queries into SQL WHERE clauses. This is sothe rego queries can be used to filter the results of a SQL query.
Index¶
- func AuditLogConverter() *sqltypes.VariableConverter
- func ConnectionLogConverter() *sqltypes.VariableConverter
- func ConvertRegoAst(cfg ConvertConfig, partial *rego.PartialQueries) (sqltypes.BooleanNode, error)
- func DefaultVariableConverter() *sqltypes.VariableConverter
- func NoACLConverter() *sqltypes.VariableConverter
- func TemplateConverter() *sqltypes.VariableConverter
- func UserConverter() *sqltypes.VariableConverter
- func WorkspaceConverter() *sqltypes.VariableConverter
- type ACLMappingVar
- func (g ACLMappingVar) ContainsSQL(cfg *sqltypes.SQLGenerator, other sqltypes.Node) (string, error)
- func (g ACLMappingVar) ConvertVariable(rego ast.Ref) (sqltypes.Node, bool)
- func (g ACLMappingVar) SQLString(cfg *sqltypes.SQLGenerator) string
- func (ACLMappingVar) UseAs() sqltypes.Node
- func (g ACLMappingVar) UsingSubfield(subfield string) ACLMappingVar
- type ConvertConfig
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcAuditLogConverter¶added inv2.14.0
func AuditLogConverter() *sqltypes.VariableConverter
funcConnectionLogConverter¶added inv2.25.0
func ConnectionLogConverter() *sqltypes.VariableConverter
funcConvertRegoAst¶
func ConvertRegoAst(cfgConvertConfig, partial *rego.PartialQueries) (sqltypes.BooleanNode,error)
ConvertRegoAst converts partial rego queries into a single SQL whereclause. If the query equates to "true" then the user should have access.
funcDefaultVariableConverter¶
func DefaultVariableConverter() *sqltypes.VariableConverter
funcNoACLConverter¶
func NoACLConverter() *sqltypes.VariableConverter
NoACLConverter should be used when the target SQL table does not containgroup or user ACL columns.
funcTemplateConverter¶
func TemplateConverter() *sqltypes.VariableConverter
funcUserConverter¶
func UserConverter() *sqltypes.VariableConverter
funcWorkspaceConverter¶added inv2.8.0
func WorkspaceConverter() *sqltypes.VariableConverter
Types¶
typeACLMappingVar¶added inv2.26.0
type ACLMappingVar struct {// SelectSQL is used to `SELECT` the ACL mapping from the table for the// given resource. ie. if the full query might look like `SELECT group_acl// FROM things;` then you would want this to be `"group_acl"`.SelectSQLstring// IndexMatcher handles variable references when indexing into the mapping.// (ie. `input.object.acl_group_list[input.object.org_owner]`). We need one// from the local context because the global one might not be correctly// scoped.IndexMatchersqltypes.VariableMatcher// Used if the action list isn't directly in the ACL entry. For example, in// the `workspaces.group_acl` and `workspaces.user_acl` columns they're stored// under a `"permissions"` key.Subfieldstring// StructPath represents the path of the value in rego// ie. input.object.group_acl -> ["input", "object", "group_acl"]StructPath []string// Instance fieldsSourcesqltypes.RegoSourceGroupNodesqltypes.Node}
ACLMappingVar is a variable matcher that matches ACL map variables to theirSQL storage. Usually the actual backing implementation is a pair of `jsonb`columns named `group_acl` and `user_acl`. Each column contains an object thatlooks like...
```json
{ "<actor_id>": ["<action>", "<action>"]}
```
funcACLMappingMatcher¶added inv2.26.0
func ACLMappingMatcher(indexMatchersqltypes.VariableMatcher, selectSQLstring, structPath []string)ACLMappingVar
func (ACLMappingVar)ContainsSQL¶added inv2.26.0
func (gACLMappingVar) ContainsSQL(cfg *sqltypes.SQLGenerator, othersqltypes.Node) (string,error)
func (ACLMappingVar)ConvertVariable¶added inv2.26.0
func (ACLMappingVar)SQLString¶added inv2.26.0
func (gACLMappingVar) SQLString(cfg *sqltypes.SQLGenerator)string
func (ACLMappingVar)UseAs¶added inv2.26.0
func (ACLMappingVar) UseAs()sqltypes.Node
func (ACLMappingVar)UsingSubfield¶added inv2.26.0
func (gACLMappingVar) UsingSubfield(subfieldstring)ACLMappingVar
typeConvertConfig¶
type ConvertConfig struct {// VariableConverter is called each time a var is encountered. This creates// the SQL ast for the variable. Without this, the SQL generator does not// know how to convert rego variables into SQL columns.VariableConvertersqltypes.VariableMatcher}
ConvertConfig is required to generate SQL from the rego queries.