Skip to content

[cloud][CLOUD-79] Put some graphql routes behind organization related feature flag

Administrator requested to merge milan-CLOUD-79 into main

Created by: kopancek

Description

This change puts all newly added graphql routes for organizations code host connections and repositories behind a feature flag

This way we can control which organizations have access to the feature. This is needed for easier support of Early Access customers

Related issue

https://sourcegraph.atlassian.net/browse/CLOUD-79

Screenshots

Screenshot 2021-10-21 at 14 20 51

Testing locally

To test locally, you need to follow these steps:

  1. start sourcegraph with EXTSVC_CONFIG_ALLOW_EDITS=true sg start dotcom
  2. Create a user, and modify the user tags in postgres:
UPDATE users SET tags = '{OrgsCode}' WHERE id = 1;
  1. Add an organization and yourself as a member of it
  2. You should be able to see the organization codehost connections and repository views. But the graphql call to add a codehost connection should fail.
  3. Go to API console and add a feature flag called org-code, with a default value of false by running the following mutation:
mutation CreateFeatureFlag{
  createFeatureFlag(
    name: "org-code",
    value: false,
  ){
    __typename
  }
}
  1. The behavior should still be the same as before
  2. Create a feature flag override, with an override for organization you created and a value of true. The value for namespace is base64 encoded, e.g. 'Org: 1' if ID of your organization is 1:
mutation CreateFeatureFlagOverride{
  createFeatureFlagOverride(
    namespace: "T3JnOjE=", 
    flagName: "org-code",
    value: true,
  ){
    __typename
  }
}
  1. The graphql call to add a codehost connection should work now, same for the organization repositories.

Follow-up work

This is not completely finished. We need to do a similar check on the UI side of things, not to show the screens if the feature flag is false

Merge request reports

Loading