1Open(Policy)                                                      Open(Policy)
2
3
4

NAME

6       opa-eval - Evaluate a Rego query
7
8
9

SYNOPSIS

11       opa eval  [flags]
12
13
14

DESCRIPTION

16       Evaluate a Rego query and print the result.
17
18

Examples

20       To evaluate a simple query:
21
22
23              $ opa eval 'x = 1; y = 2; x < y'
24
25
26
27       To evaluate a query against JSON data:
28
29
30              $ opa eval --data data.json 'data.names[_] = name'
31
32
33
34       To evaluate a query against JSON data supplied with a file:// URL:
35
36
37              $ opa eval --data file:///path/to/file.json 'data'
38
39
40

File Bundle Loading

42       The  --bundle  flag  will  load data files and Rego files contained the
43       bundle specified by the path. It can be either a compressed tar archive
44       bundle file or a directory tree.
45
46
47              $ opa eval --bundle /some/path 'data'
48
49
50
51       Where /some/path contains:
52
53
54              foo/
55                |
56                +-- bar/
57                |     |
58                |     +-- data.json
59                |
60                +-- baz_test.rego
61                |
62                +-- manifest.yaml
63
64
65
66       The  JSON  file  'foo/bar/data.json'  would  be loaded and rooted under
67       package path contained inside the file. Only data files named data.json
68       or  data.yaml  will  be  loaded. In the example above the manifest.yaml
69       would be ignored.
70
71
72       See   https://www.openpolicyagent.org/docs/latest/bundles/   for   more
73       details on bundle directory structures.
74
75
76       The --data flag can be used to recursively load ALL *.rego, *.json, and
77       *.yaml files under the specified directory.
78
79

Output Formats

81       Set the output format with the --format flag.
82
83
84              --format=json      : output raw query results as JSON
85              --format=values    : output line separated JSON arrays containing expression values
86              --format=bindings  : output line separated JSON objects containing variable bindings
87              --format=pretty    : output query results in a human-readable format
88
89
90
91

OPTIONS

93       -b, --bundle=""      set bundle file(s) or directory path(s). This flag
94       can be repeated.
95
96
97       --coverage[=false]      report coverage
98
99
100       -d,  --data=""       set  policy  or  data  file(s).  This  flag can be
101       repeated.
102
103
104       --disable-indexing[=false]      disable indexing optimizations
105
106
107       --disable-inlining=[]      set  paths  of  documents  to  exclude  from
108       inlining
109
110
111       --explain=off      enable query explanations
112
113
114       --fail[=false]       exits  with  non-zero exit code on undefined/empty
115       result and errors
116
117
118       --fail-defined[=false]       exits   with   non-zero   exit   code   on
119       defined/non-empty result and errors
120
121
122       -f, --format=json      set output format
123
124
125       -h, --help[=false]      help for eval
126
127
128       --ignore=[]       set file and directory names to ignore during loading
129       (e.g., '.*' excludes hidden files)
130
131
132       --import=""      set query import(s). This flag can be repeated.
133
134
135       -i, --input=""      set input file path
136
137
138       --instrument[=false]      enable query instrumentation metrics (implies
139       --metrics)
140
141
142       --metrics[=false]      report query performance metrics
143
144
145       --package=""      set query package
146
147
148       -p, --partial[=false]      perform partial evaluation
149
150
151       --pretty-limit=80       set  limit after which pretty output gets trun‐
152       cated
153
154
155       --profile[=false]      perform expression profiling
156
157
158       --profile-limit=10      set number of profiling results to show
159
160
161       --profile-sort=""      set sort order of expression profiler results
162
163
164       --shallow-inlining[=false]      disable inlining of rules  that  depend
165       on unknowns
166
167
168       --stdin[=false]      read query from stdin
169
170
171       -I, --stdin-input[=false]      read input document from stdin
172
173
174       -u,  --unknowns=[input]       set paths to treat as unknown during par‐
175       tial evaluation
176
177
178

SEE ALSO

180       opa(1)
181
182
183
1842020                              Agent(1)Oct                     Open(Policy)
Impressum