Skip to content

Commit b59b741

Browse files
chore: Replace backend with platform
We have migrated to a new set of backend services and are deprecating the existing python based services. This work in progress replaces the sample code
1 parent d00d3ab commit b59b741

File tree

6 files changed

+143
-34
lines changed

6 files changed

+143
-34
lines changed

.github/workflows/build.yaml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,37 +146,36 @@ jobs:
146146
path: lib/
147147
- name: Git clone backend
148148
run: |
149-
git clone https://github.com/opentdf/opentdf.git
150-
- uses: yokawasa/action-setup-[email protected]
149+
git clone https://github.com/opentdf/platform.git
150+
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
151151
with:
152-
setup-tools: |
153-
kubectl
154-
helm
155-
tilt
156-
# This should be in sync with the minikube-deployed kube version below
157-
kubectl: '1.23.1'
158-
helm: '3.8.0'
159-
tilt: '0.26.2'
152+
go-version: "1.21.8"
153+
cache-dependency-path: |
154+
platform/service/go.sum
155+
platform/examples/go.sum
156+
platform/protocol/go/go.sum
157+
platform/sdk/go.sum
160158
- run: |
161-
kubectl version --client
162-
kustomize version
163-
tilt version
164-
- name: start minikube
165-
id: minikube
166-
uses: medyagh/setup-minikube@master
159+
cd platform
160+
docker compose up -d --wait --wait-timeout 240
161+
.github/scripts/init-temp-keys.sh
162+
cp opentdf-example.yaml opentdf.yaml
163+
go run ./service provision keycloak
164+
- uses: JarvusInnovations/background-action@313d37130873d82c33fc907b9b78e932aec8e990
165+
name: start kas
167166
with:
168-
minikube-version: 1.25.1
169-
# This should be in sync with the setup-tools version above
170-
kubernetes-version: 1.23.1
171-
- name: Run tilt ci
172-
env:
173-
#path relative to the quickstart Tiltfile
174-
TEST_SCRIPT: ../../wait-and-test.sh
175-
OPENTDF_INGRESS_HOST_PORT: "5432"
176-
OPENTDF_LOAD_FRONTEND: "false"
167+
run: |
168+
go run ./service start
169+
wait-on: |
170+
tcp:localhost:8080
171+
log-output-if: true
172+
wait-for: 90s
173+
working-directory: platform
174+
- env:
175+
OPENTDF_SERVICES_AUTHORIZATION_URL: "http://localhost:65432/"
177176
PLAYWRIGHT_TESTS_TO_RUN: roundtrip
178177
run: |-
179-
tilt ci --file opentdf/quickstart/Tiltfile
178+
./.github/workflows/roundtrip/wait-and-test.sh
180179
181180
deliver-ghp:
182181
needs: [lib, web-app, scripts, backend-roundtrip]

.github/workflows/roundtrip/wait-and-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _wait-for() {
1313
echo "[INFO] In retry loop for quickstarted opentdf backend..."
1414
limit=5
1515
for i in $(seq 1 $limit); do
16-
if curl --show-error --fail --insecure http://localhost:65432/api/kas; then
16+
if curl --show-error --fail --insecure http://localhost:8080; then
1717
return 0
1818
fi
1919
if [[ $i == "$limit" ]]; then

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ Start a local, blank cluster. See [Integrate](https://github.com/opentdf/opentdf
2828
const cipherText = await client.encrypt(plainText);
2929
const clearText = await client.decrypt(cipherText);
3030
```
31-
### Examples
32-
33-
Review examples to see how to integrate. See [Examples](https://github.com/opentdf/opentdf/tree/main/examples)
3431

3532
## Distribute
3633

@@ -58,3 +55,4 @@ nvm use
5855
make test
5956
make start
6057
```
58+

scripts/demo-evironment.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
6+
ROOT_DIR="$(cd "${APP_DIR}/.." >/dev/null && pwd)"
7+
8+
_run_platform() {
9+
git clone https://github.com/opentdf/platform.git
10+
cd platform
11+
# TODO Modify docker-compose.yaml as follows:
12+
# KC_HOSTNAME_PORT: "65432"
13+
docker compose up -d --wait --wait-timeout 240
14+
.github/scripts/init-temp-keys.sh
15+
16+
# TODO Modify opentdf-example.yaml as follows:
17+
# KC_HOSTNAME_PORT: "65432"
18+
cp opentdf-example.yaml opentdf.yaml
19+
go run ./service provision keycloak
20+
}
21+
22+
_wait-for() {
23+
echo "[INFO] In retry loop for quickstarted opentdf backend..."
24+
limit=5
25+
for i in $(seq 1 $limit); do
26+
if curl --show-error --fail --insecure http://localhost:8080; then
27+
return 0
28+
fi
29+
if [[ $i == "$limit" ]]; then
30+
echo "[WARN] Breaking _wait-for loop as we are at limit"
31+
break
32+
fi
33+
sleep_for=$((10 + i * i * 2))
34+
echo "[INFO] retrying in ${sleep_for} seconds... ( ${i} / $limit ) ..."
35+
sleep ${sleep_for}
36+
done
37+
echo "[ERROR] Couldn't connect to opentdf backend"
38+
exit 1
39+
}
40+
41+
_init_server() {
42+
output=$(mktemp)
43+
if ! cd "${WEB_APP_DIR}"; then
44+
echo "[ERROR] unable to cd ${WEB_APP_DIR}"
45+
exit 2
46+
fi
47+
npm uninstall @opentdf/client
48+
if ! npm ci; then
49+
echo "[ERROR] Couldn't ci web-app"
50+
exit 2
51+
fi
52+
if ! npm i "../lib/opentdf-client-${app_version}.tgz"; then
53+
ls -ls ../lib/
54+
echo "[ERROR] Couldn't install @opentdf/client tarball"
55+
return 1
56+
fi
57+
npm run dev &>"$output" &
58+
server_pid=$!
59+
echo "Server pid: $server_pid"
60+
echo "Output: $output"
61+
echo "Wait:"
62+
limit=5
63+
for i in $(seq 1 $limit); do
64+
if grep -q -i 'ready' "$output"; then
65+
return 0
66+
fi
67+
if ! ps $server_pid >/dev/null; then
68+
echo "The server died" >&2
69+
cat "${output}"
70+
exit 1
71+
fi
72+
if [[ $i == "$limit" ]]; then
73+
echo "[WARN] Breaking _init_server loop after ${limit} iterations"
74+
cat "${output}"
75+
break
76+
fi
77+
sleep_for=$((5 + i * i * 2))
78+
echo "[INFO] retrying in ${sleep_for} seconds... ( ${i} / $limit ) ..."
79+
sleep ${sleep_for}
80+
done
81+
}
82+
83+
if ! _init_server; then
84+
echo "[ERROR] Couldn't run web app server"
85+
exit 2
86+
fi
87+
88+
if ! _wait-for; then
89+
exit 1
90+
fi
91+
92+
if ! cd "${WEB_APP_DIR}"; then
93+
echo "[ERROR] Couldn't cd to web-app dir, [${WEB_APP_DIR}]"
94+
exit 2
95+
fi
96+
97+
if ! cd tests; then
98+
echo "[ERROR] Couldn't open web integration tests folder"
99+
exit 2
100+
fi
101+
102+
if ! npm i; then
103+
echo "[ERROR] Unable to install integration tests deps"
104+
exit 2
105+
fi
106+
107+
if ! npx playwright install --with-deps; then
108+
echo "[ERROR] Unable to install playwright"
109+
exit 2
110+
fi
111+
112+
npm test

web-app/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ function decryptedFileExtension(encryptedFileName: string): string {
3030
}
3131

3232
const oidcClient = new OidcClient(
33-
'http://localhost:65432/auth/realms/tdf',
34-
'browsertest',
33+
'http://localhost:65432/auth/realms/opentdf',
34+
'opentdf',
3535
'otdf-sample-web-app'
3636
);
3737

web-app/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default defineConfig({
1515
server: {
1616
port: 65432,
1717
proxy: {
18-
'/api': 'http://localhost:5432',
19-
'/auth': 'http://localhost:5432',
18+
'/kas': 'http://localhost:5432',
19+
'/auth': 'http://localhost:8888',
2020
},
2121
},
2222
});

0 commit comments

Comments
 (0)