proj-gauchoride-staff

Environment Variables are set up in .env.SAMPLE

Any environment variables needed in the application should be put into .env.SAMPLE

The actual values go into a file .env that is copied from .env.SAMPLE, but that is NOT committed to the repo.

Environment Variables should have default values

When adding new properties to the application that are necessary for the application to run, it is helpful to have fallback values, especially if those values are not accessed during tests.

As an example, in src/main/resources/application.properties, we see lines that contain fallback values for GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET and ADMIN_EMAILS:

spring.security.oauth2.client.registration.google.client-id=${GOOGLE_CLIENT_ID:${env.GOOGLE_CLIENT_ID:client_id_unset}}
spring.security.oauth2.client.registration.google.client-secret=${GOOGLE_CLIENT_SECRET:${env.GOOGLE_CLIENT_SECRET:client_secret_unset}}
spring.security.oauth2.client.registration.google.scope=email,profile
...
app.admin.emails=${ADMIN_EMAILS:${env.ADMIN_EMAILS:phtcon@ucsb.edu}}

The fallback values, in this case being:

Env variable Default Value
GOOGLE_CLIENT_ID client_id_unset
GOOGLE_CLIENT_SECRET client_secret_unset
ADMIN_EMAILS phtcon@ucsb.edu

While the values for GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET will not work in practice (i.e. with these values, OAuth login will fail), having a default value:

It is recommended that if/when any additional environment variables are added to .env.SAMPLE that similar fallback values be included in the .properties files.