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 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
- type ACLGroupVar
- type ConvertConfig
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
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¶added inv0.26.2
func UserConverter() *sqltypes.VariableConverter
Types¶
typeACLGroupVar¶
type ACLGroupVar struct {StructSQLstring// input.object.group_acl -> ["input", "object", "group_acl"]StructPath []string// FieldReference handles referencing the subfields, which could be// more variables. We pass one in as the global one might not be correctly// scoped.FieldReferencesqltypes.VariableMatcher// Instance fieldsSourcesqltypes.RegoSourceGroupNodesqltypes.Node}
ACLGroupVar is a variable matcher that handles group_acl and user_acl.The sql type is a jsonb object with the following structure:
"group_acl": { "<group_name>": ["<actions>"]}
This is a custom variable matcher as json objects have arbitrary complexity.
funcACLGroupMatcher¶
func ACLGroupMatcher(fieldReferencesqltypes.VariableMatcher, structSQLstring, structPath []string)ACLGroupVar
func (ACLGroupVar)ContainsSQL¶
func (gACLGroupVar) ContainsSQL(cfg *sqltypes.SQLGenerator, othersqltypes.Node) (string,error)
func (ACLGroupVar)ConvertVariable¶
func (ACLGroupVar)SQLString¶
func (gACLGroupVar) SQLString(cfg *sqltypes.SQLGenerator)string
func (ACLGroupVar)UseAs¶
func (ACLGroupVar) UseAs()sqltypes.Node
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.