Skip to content

Require fewer secrets for local dev #216

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 4 commits into from
Oct 7, 2020
Merged

Require fewer secrets for local dev #216

merged 4 commits into from
Oct 7, 2020

Conversation

mxmeinhold
Copy link
Collaborator

This PR gets most of the way to enabling secretless local development, but not quite.

I haven't wrapped SSO to enable developing completely offline, but this PR adds:

  • Local postgresql instructions for running in a container
  • LDAPWrapper to allow mocking accounts and decouple from ldap
  • Prevents errors by disabling onesignal if secrets aren't configured
  • Expands the logging on initialisation a little to show more of what's running locally

SSO will need a wrapper or overrides for the core methods, similar to LDAPWrapper, which is beyond what I'm prepared to do at the moment.

This should make hacktoberfest somewhat simpler, as well as making it easier to work in codespaces (though this is still heavily limited by sso).

Set up ldap 'mock' to allow for testing without access to actual ldap,
and for mocking out fake accounts to test various features
@mxmeinhold mxmeinhold added the hacktoberfest-accepted Approved Hacktoberfest contributions label Oct 7, 2020
@mxmeinhold mxmeinhold requested a review from devinmatte October 7, 2020 17:31
Copy link
Member

@devinmatte devinmatte left a comment

Choose a reason for hiding this comment

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

This looks great! We should do the same on a few other projects to enable easier local dev after we've graduated

@mxmeinhold
Copy link
Collaborator Author

That's the plan, once I remember to get around to it.

@mxmeinhold mxmeinhold merged commit 6c0c250 into develop Oct 7, 2020
@mxmeinhold mxmeinhold deleted the local-dev branch October 7, 2020 17:40
You can use an existing database, like the instance used for the dev branch, use a database on another server, or spin up a container using docker or podman.
To get setup using docker, run
```bash
docker run --name packet-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not just toss this into a docker-compose file, like I did for self-service?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I use podman, so docker-compose is not something I default to yet.

After the container starts up, you should be able to connect with the connection string `postgresql://postgres:mysecretpassword@localhost:5432/postgres`, which is the default connection string in `config.env.py`.
Once the container is up, run the following to set up the database tables.
```bash
flask db upgrade
Copy link
Member

Choose a reason for hiding this comment

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

We should really get in the habit of having the application itself run migrations automatically when it starts. I'm not sure there is any reason not to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Approved Hacktoberfest contributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants