Skip to content

[server] Add spicedb client #16197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2023
Merged

[server] Add spicedb client #16197

merged 1 commit into from
Feb 6, 2023

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Feb 3, 2023

Description

Adds basic spicedb client. We'll likely need to adjust a few things, but this helps keep subsequent changes smaller, and it ensures we land the spicedb dependency without too many other changes.

Related Issue(s)

How to test

  1. Server comes up in preview

Release Notes

NONE

Documentation

Build Options:

  • /werft with-github-actions
    Experimental feature to run the build with GitHub Actions (and not in Werft).
  • leeway-no-cache
    leeway-target=components:all
  • /werft no-test
    Run Leeway with --dont-test
  • /werft publish-to-npm

Preview Environment Options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@easyCZ easyCZ requested a review from a team February 3, 2023 11:02
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mp-spicedb-server-client.2 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added the size/M label Feb 3, 2023
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Feb 3, 2023
Comment on lines 12 to 27
export function spicedbClientFromEnv(): v1.ZedPromiseClientInterface {
const token = process.env["SPICEDB_PRESHARED_KEY"];
if (!token) {
throw new Error("No spicedb token configured.");
}

const address = process.env["SPICEDB_ADDRESS"];
if (!address) {
throw new Error("No spicedb address configured.");
}

const client = v1.NewClient(token, address, v1.ClientSecurity.INSECURE_PLAINTEXT_CREDENTIALS);
return client.promises;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it, do we need to guard for the case where the experimental config for SpiceDB is not set, and therefore SpiceDB doesn't exist? This could then prevent the instance from starting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed this by making the type possibly undefined. The constructor no longer throws, when the env vars are undefined. The use of the client can then check.

@easyCZ easyCZ force-pushed the mp/spicedb-server-client branch from 0ddda96 to 2a69ecb Compare February 3, 2023 11:05
@easyCZ
Copy link
Member Author

easyCZ commented Feb 3, 2023

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-mp-spicedb-server-client.4
(with .werft/ from main)

@easyCZ
Copy link
Member Author

easyCZ commented Feb 6, 2023

/werft run

👍 started the job as gitpod-build-mp-spicedb-server-client.6
(with .werft/ from main)

@easyCZ
Copy link
Member Author

easyCZ commented Feb 6, 2023

/unhold

@roboquat roboquat merged commit 52653a2 into main Feb 6, 2023
@roboquat roboquat deleted the mp/spicedb-server-client branch February 6, 2023 09:14
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants