Skip to content

Commit 50cc289

Browse files
Merge pull request open-policy-agent#17 from tsandall/set-clarity
Refined set syntax and more
2 parents d5fe834 + d42bf83 commit 50cc289

File tree

3 files changed

+116
-112
lines changed

3 files changed

+116
-112
lines changed

docs/CONCEPTS.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ Content-Type: text/plain
8686
8787
package opa.examples
8888
89-
violations[] = server :-
90-
server = data.servers[]
91-
server.protocols[] = "http"
92-
server.ports[] = data.ports[i].id
93-
data.ports[i].networks[] = data.networks[j].id
89+
violations[server] :-
90+
server = data.servers[_]
91+
server.protocols[_] = "http"
92+
server.ports[_] = data.ports[i].id
93+
data.ports[i].networks[_] = data.networks[j].id
9494
data.networks[j].public = true
9595
```
9696

@@ -190,7 +190,7 @@ Conceptually, there are two kinds of documents in OPA:
190190

191191
When defining policies, rules are written which contain expressions that reference documents. The language that rules are written in ("Opalog") lets you reference base documents and virtual documents in exactly the same way.
192192

193-
<img src="https://cdn.rawgit.com/open-policy-agent/opa/9f5f1e6fa68fd0ee627122b9e5c8809519e5bba8/docs/data-model-logical.svg" />
193+
<img src="https://cdn.rawgit.com/open-policy-agent/opa/86672fab147c476cb8e8b0950b6c4fd48b5b2014/docs/data-model-logical.svg" />
194194

195195
## <a name="policies"></a> Policies
196196

@@ -243,15 +243,15 @@ import data.servers # import the data.servers docume
243243
import data.networks # same but for data.networks
244244
import data.ports # same but for data.ports
245245
246-
violations[] = server :- # a server exists in the violations set if:
247-
server = servers[] # the server exists in the servers collection
248-
server.protocols[] = "http" # and the server has http in its protocols collection
249-
public_servers[] = server # and the server exists in the public_servers collection
246+
violations[server] :- # a server exists in the violations set if:
247+
server = servers[_], # the server exists in the servers collection
248+
server.protocols[_] = "http", # and the server has http in its protocols collection
249+
public_servers[server] # and the server exists in the public_servers set
250250
251-
public_servers[] = server :- # a server exists in the public_servers set if:
252-
server = servers[] # the server exists in the servers collection
253-
server.ports[] = ports[i].id # and the server is connected to a port in the ports collection
254-
ports[i].networks[] = networks[j].id # and the port is connected to a network in the networks collection
251+
public_servers[server] :- # a server exists in the public_servers set if:
252+
server = servers[_], # the server exists in the servers collection
253+
server.ports[_] = ports[i].id, # and the server is connected to a port in the ports collection
254+
ports[i].networks[_] = networks[j].id, # and the port is connected to a network in the networks collection
255255
networks[j].public = true # and the network is public
256256
```
257257

0 commit comments

Comments
 (0)