~egtann/sum

ref: 2660c9cffee148e30de81b40d1e3c8561c5cd027 sum/sum.go -rw-r--r-- 521 bytes
2660c9cf — Evan Tann remove unused make clean command 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package sum

import (
	"fmt"
	"io"
)

// BuildPermissions for each user.
func BuildPermissions(
	db Store,
	r io.Reader,
) (map[string]*Permissions, error) {
	schema, err := db.GetSchema()
	if err != nil {
		return nil, fmt.Errorf("get schema: %w", err)
	}
	allStatements := db.Statements()
	ast, err := parse(r)
	if err != nil {
		return nil, fmt.Errorf("parse: %w", err)
	}
	userPerms, err := compile(schema, allStatements, ast)
	if err != nil {
		return nil, fmt.Errorf("compile: %w", err)
	}
	return userPerms, nil
}