Support applying a configuration to the DB from a file
Created by: slimsag
In Sourcegraph 3.0 we switched to using the DB purely as the authoritative source for configuration. This was a good change for various reasons, mainly the ability to edit configuration via the web UI on cluster deployments of Sourcegraph.
However, in some situations it is desirable to only allow modifying the configuration through a config file. The primary situation being to ensure that all configuration changes go through a standard code review process within an organization. Our assumption currently is that most organizations will be OK with editing the config through the web UI and will not want to do this, but for these exceptional cases:
On the frontend deployment you would set:
SITE_CONFIG_FILE=/etc/sourcegraph/site-config.json # site configuration
CRITICAL_CONFIG_FILE=/etc/sourcegraph/critical-config.json # management console configuration
As a site admin, you would be responsible for e.g. creating the config map YAML and mounting the config file into the frontend container. We would not provide this as a standard in deploy-sourcegraph.
When set, the contents of those files would be saved to the DB (as if you did it through the UI), and we would reject any attempts to make changes through the UI with an error like:
Making changes to the [site|critical] configuration through the UI has been prohibited by the site admin.
This feature is for https://app.hubspot.com/contacts/2762526/company/464956351