Skip to content

Commit 7ac1869

Browse files
committed
data-playground: adjust for /v1/compile
1 parent 76958e2 commit 7ac1869

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

Caddyfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
handle /v1/* {
77
reverse_proxy http://eopa:8181
88
}
9-
handle /exp/* {
10-
reverse_proxy http://eopa:8181
11-
}
129

1310
handle {
1411
root * /usr/share/caddy

Caddyfile-local

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
reverse_proxy http://127.0.0.1:8181
77
}
88

9-
handle /exp/* { # EOPA
10-
reverse_proxy http://127.0.0.1:8181
11-
}
12-
139
handle { # Observable Framework's dev server
1410
reverse_proxy http://127.0.0.1:3000
1511
}

docker-compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
- eopa
88

99
eopa:
10-
image: ${EOPA_IMAGE:-ghcr.io/styrainc/enterprise-opa:edge}
10+
image: ${EOPA_IMAGE:-ghcr.io/styrainc/enterprise-opa:latest}
1111
pull_policy: ${EOPA_PULL_POLICY:-always}
1212
ports:
1313
- "8181:8181"
@@ -17,6 +17,5 @@ services:
1717
- --addr=:8181
1818
- --log-level=debug
1919
- --no-license-fallback
20-
- --set=plugins.exp_compile_api={}
2120
environment:
2221
EOPA_LICENSE_KEY: ${EOPA_LICENSE_KEY:-}

src/components/RegoEditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function RegoEditor({
3636
}
3737
// If we make it this far, the policy is on the server, so let's compile it:
3838
const { result, errors } = await (await compilePolicy(opa, input, mappings)).json();
39-
const query = result;
39+
const { query } = result;
4040
if (errors) {
4141
parent.value = String(""); // this means "no query produced"
4242
parent.dispatchEvent(new InputEvent("input", {bubbles: true}));
@@ -53,7 +53,7 @@ export function RegoEditor({
5353
});
5454
}
5555

56-
parent.value = String(result); // TODO(sr) check this
56+
parent.value = String(query);
5757
parent.dispatchEvent(new InputEvent("input", {bubbles: true}));
5858
return [];
5959
}, {

src/components/helpers.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ export async function putPolicy(opa, id, code, raise = true) {
1111
}
1212

1313
export async function compilePolicy(opa, input, mappings = {}, query = "data.filters.include") {
14-
const resp = await fetch(`${opa}exp/compile`, {
14+
const resp = await fetch(`${opa}v1/compile`, {
1515
method: "POST",
1616
body: JSON.stringify({
1717
input,
1818
query,
1919
options: {
20-
dialect: "postgres",
21-
targetSQLTableMappings: mappings,
20+
targetSQLTableMappings: {
21+
postgres: mappings,
22+
},
2223
},
2324
}),
2425
headers: {
2526
"Content-Type": "application/json",
26-
"Accept": "application/vnd.styra.sql+json"
27+
"Accept": "application/vnd.styra.sql.postgres+json"
2728
},
2829
});
2930
return resp;

src/policies/filters.rego

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ include if {
1919
input.products.price < 500
2020
input.users.name == user
2121
}
22-
23-
_use_metadata := rego.metadata.rule()

0 commit comments

Comments
 (0)