~egtann/sum

sum/sum.go -rw-r--r-- 521 bytes
7143d724 — Evan Tann add go1.15 workaround for broken google tls certs 2 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
}