Wrap sourcegraph in feature flag and user opt-in
------------
DB Migration
------------
This commit contains a DB migration adding the following fields:
- `applicaiton_settings::sourcegraph_public_only` this is helpful for
managing the difference between self-hosted and gitlab.com, where on
.com Sourcegraph is not authorized to see private projects, but in a
self-hosted instance, it's based on the authentication token they
preconfigure with their private sourcegraph instance.
- `user_preferences::sourcegraph_enabled` this is used to determine
if the user has opted in for sourcegraph or not.
------------
Feature flag
------------
Example:
```
Feature.enable(:sourcegraph, Project.find_by_full_path('lorem/ipsum'))
```
It is possible to conditionally apply this feature flag, so that the
bundle is only loaded on certain projects. This makes showing the admin
(or user) settings based on this flag difficult since there is no project
or group in scope for these views. For this reason, we've introduced the
`Gitlab::Sourcegraph` module to encapsulate whether a feature is
available (conditionally or globally).
How?
Conditional or global enablement can be tested with:
```
!Feature.get(:sourcegraph).off?
```
https://github.com/jnunemaker/flipper/blob/fa78a0030c7f139aecc3f9c8468baf9fd1498eb9/lib/flipper/feature.rb#L223
----
Also
----
The bundle is only loaded in project routes (potential for further optimization here)
Loading