MCPcopy Index your code
hub / github.com/coder/coder / Compile

Function Compile

coderd/rbac/authz.go:730–751  ·  view source on GitHub ↗
(cfg regosql.ConvertConfig, pa *PartialAuthorizer)

Source from the content-addressed store, hash-verified

728}
729
730func Compile(cfg regosql.ConvertConfig, pa *PartialAuthorizer) (AuthorizeFilter, error) {
731 root, err := regosql.ConvertRegoAst(cfg, pa.partialQueries)
732 if err != nil {
733 return nil, xerrors.Errorf("convert rego ast: %w", err)
734 }
735
736 // Generate the SQL
737 gen := sqltypes.NewSQLGenerator()
738 sqlString := root.SQLString(gen)
739 if len(gen.Errors()) > 0 {
740 var errStrings []string
741 for _, err := range gen.Errors() {
742 errStrings = append(errStrings, err.Error())
743 }
744 return nil, xerrors.Errorf("sql generation errors: %v", strings.Join(errStrings, ", "))
745 }
746
747 return &authorizedSQLFilter{
748 sqlString: sqlString,
749 auth: pa,
750 }, nil
751}
752
753func (a *authorizedSQLFilter) SQLString() string {
754 return a.sqlString

Callers 2

testAuthorizeFunction · 0.85
CompileToSQLMethod · 0.85

Calls 6

ErrorsMethod · 0.95
ConvertRegoAstFunction · 0.92
NewSQLGeneratorFunction · 0.92
SQLStringMethod · 0.65
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by 1

testAuthorizeFunction · 0.68