Skip to content
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

Run migrations on API initialization, add /admin/db/{action} endpoints #224

Merged
merged 11 commits into from
Nov 12, 2021

Conversation

PSalant726
Copy link
Contributor

@PSalant726 PSalant726 commented Nov 12, 2021

Closes #202
Closes #204

Code Changes

  • Automatically load the default taxonomy on API initialization
  • Update fidesctl init-db to be an API call
  • Update fidesctl reset-db to be an API call

Steps to Confirm

  • make cli runs without errors
  • No errors printed to container logs
  • Manually run fidesctl init-db
  • Manually run fidesctl reset-db

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Documentation Updated

Description Of Changes

  • The two endpoints added to the API are /admin/db/{action} where action may be either init or reset
  • As a security best practice, and before this is merged, the database_url value should be passed from the CLI to the API via POST body, not via query param (as it is at the time of opening this PR).

Removes the need for new users to run `fidesctl init-db` immediately
after loading a fresh CLI env with `make cli`.

Fidesapi now also loads the default taxonomy without requiring itself -
by interacting directly with the database to "upsert" the default
taxonomy's resources. Uses and `INSERT` + `ON CONFLICT...DO UPDATE`, to
simplify the process for systems that have previously loaded the
default taxonomy, or some other variation.
Prevents the CLI from interacting directly with the database by adding
a new API endpoint, `/admin/init-db`, and uses it instead.
Further reduces direct database interaction from the CLI by enabling
resetting of the fides database via the API, and using the endpoint
when running the `fidesctl reset-db` command.
@PSalant726 PSalant726 self-assigned this Nov 12, 2021
@PSalant726 PSalant726 added documentation Improvements or additions to documentation enhancement labels Nov 12, 2021
fidesctl/src/fidesapi/crud.py Outdated Show resolved Hide resolved
fidesctl/src/fidesctl/cli/cli.py Outdated Show resolved Hide resolved
fidesctl/src/fidesctl/core/api.py Outdated Show resolved Hide resolved
Enables the auto-generated documentation to show the available path
parameters for the `/admin/db/{action}` endpoint.
@ThomasLaPiana ThomasLaPiana merged commit 75ec54a into main Nov 12, 2021
@ThomasLaPiana ThomasLaPiana deleted the ps/migrate-on-start branch November 12, 2021 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
2 participants