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

Function regoPartialInputValue

coderd/rbac/astvalue.go:39–66  ·  view source on GitHub ↗

regoPartialInputValue is the same as regoInputValue but only includes the object type. This is for partial evaluations.

(subject Subject, action policy.Action, objectType string)

Source from the content-addressed store, hash-verified

37// regoPartialInputValue is the same as regoInputValue but only includes the
38// object type. This is for partial evaluations.
39func regoPartialInputValue(subject Subject, action policy.Action, objectType string) (ast.Value, error) {
40 regoSubj, err := subject.regoValue()
41 if err != nil {
42 return nil, xerrors.Errorf("subject: %w", err)
43 }
44
45 s := [2]*ast.Term{
46 ast.StringTerm("subject"),
47 ast.NewTerm(regoSubj),
48 }
49 a := [2]*ast.Term{
50 ast.StringTerm("action"),
51 ast.StringTerm(string(action)),
52 }
53 o := [2]*ast.Term{
54 ast.StringTerm("object"),
55 ast.NewTerm(ast.NewObject(
56 [2]*ast.Term{
57 ast.StringTerm("type"),
58 ast.StringTerm(objectType),
59 }),
60 ),
61 }
62
63 input := ast.NewObject(s, a, o)
64
65 return input, nil
66}
67
68// regoValue returns the ast.Object representation of the subject.
69func (s Subject) regoValue() (ast.Value, error) {

Callers 2

TestRegoInputValueFunction · 0.85
newPartialAuthorizerMethod · 0.85

Calls 2

regoValueMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestRegoInputValueFunction · 0.68