regoPartialInputValue is the same as regoInputValue but only includes the object type. This is for partial evaluations.
(subject Subject, action policy.Action, objectType string)
| 37 | // regoPartialInputValue is the same as regoInputValue but only includes the |
| 38 | // object type. This is for partial evaluations. |
| 39 | func 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. |
| 69 | func (s Subject) regoValue() (ast.Value, error) { |