regoValue returns the ast.Object representation of the subject.
()
| 67 | |
| 68 | // regoValue returns the ast.Object representation of the subject. |
| 69 | func (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 | |
| 105 | func (z Object) regoValue() ast.Value { |
| 106 | userACL := ast.NewObject() |
nothing calls this directly
no test coverage detected