Working with Source Code

Go Source Code Development.

Development related commands can be found in the Makefile file.

Compile from the source

Make sure you have go, make, docker, and docker-compose installed.

# Prepare dependencies
make vendor

# Compile and run the data plane and control plane
make run

One can open the local swagger UI to test the APIs:

# Compile and run the proxy plane
# It requires at least a "GET/POST /api/v1/facts" grant token to work

OPV_PROXY_PLANE_DEFAULT_DP_GRANT_TOKEN=v1:sandbox.example.com:Iy8TJZcuhicocCklFdwA make run_proxyplane

Generate swagger 2.0

When you make any change to APIs (e.g. pkg/dataplane, pkg/controlplane, pkg/apimodel), you may want to regenerate the swagger 2.0 API doc. This is done by swag.

# Regenerate swagger 2.0 docs

make swag

Notice that dataplane and controlplane’s entrypoints are separated, and they are defined in cmd/dataplane and cmd/controlplane.

Generate ent models

If you want to migrate or change the schema of the data models, please change the schema files and then run the following command to re-generate the ent related data models.

# Regenerate ent data models

make ent

Note that ent will run the auto migration for schema changes.

Generate dbdoc with tbls

This is to generate the dbdoc for Database Visualization →. We leverage a tool called https://github.com/k1LoW/tbls.

make run

# Once make run is running, open a new terminal to generate the
# database tables visualization from the default _opv.sqlite db locally.
make tbls

Tests

Unit tests:

make test

Functional tests (i.e. the integration tests):

# Note the functional tests will try to start 3 planes if they don't open ports locally

make local_functional_test

CI/CD

All the CI are run on github. Please refer to https://github.com/open-privacy/opv/blob/main/.github/workflows/ci.yml.

Currently the playground is deployed and triggered by https://github.com/open-privacy/opv/blob/main/.github/workflows/deploy_opv_playground.yml.

Edit this page on GitHub