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

Method regoValue

coderd/rbac/astvalue.go:69–103  ·  view source on GitHub ↗

regoValue returns the ast.Object representation of the subject.

()

Source from the content-addressed store, hash-verified

67
68// regoValue returns the ast.Object representation of the subject.
69func (s Subject) regoValue() (ast.Value, error) {
70 if s.cachedASTValue != nil {
71 return s.cachedASTValue, nil
72 }
73
74 subjRoles, err := s.Roles.Expand()
75 if err != nil {
76 return nil, xerrors.Errorf("expand roles: %w", err)
77 }
78
79 subjScope, err := s.Scope.Expand()
80 if err != nil {
81 return nil, xerrors.Errorf("expand scope: %w", err)
82 }
83 subj := ast.NewObject(
84 [2]*ast.Term{
85 ast.StringTerm("id"),
86 ast.StringTerm(s.ID),
87 },
88 [2]*ast.Term{
89 ast.StringTerm("roles"),
90 ast.NewTerm(regoSlice(subjRoles)),
91 },
92 [2]*ast.Term{
93 ast.StringTerm("scope"),
94 ast.NewTerm(subjScope.regoValue()),
95 },
96 [2]*ast.Term{
97 ast.StringTerm("groups"),
98 ast.NewTerm(regoSliceString(s.Groups...)),
99 },
100 )
101
102 return subj, nil
103}
104
105func (z Object) regoValue() ast.Value {
106 userACL := ast.NewObject()

Callers

nothing calls this directly

Calls 5

regoSliceFunction · 0.85
regoSliceStringFunction · 0.85
ExpandMethod · 0.65
regoValueMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected