Skip to content

Support Flipper API in GitLab Feature Flag

Shinya Maeda requested to merge support-flipper-api-in-gitlab-feature-flag into master

What does this MR do?

This is necessary component to achieve GitLab Feature Flag dogfooding issue #26842 (closed)

This feature will be shipped as alpha feature (disabled by default with gitlab_feature_flags_flipper_api flag) exclusively for dogfooding purpose, however, we consider making it GA if there is a need from Flipper community.

Closes #222265 (closed)

Key points

  • Feature Flag client can CRUD flags in Feature Flag server with instance_id authorization.
  • a

Endpoints

This MR replicates the endpoints for Flipper API

GET         /api/:version/feature_flags/flipper/:project_id/features(.:format)                                      - Get all features
POST        /api/:version/feature_flags/flipper/:project_id/features(.:format)                                      - Create a new feature
GET         /api/:version/feature_flags/flipper/:project_id/features/:feature_name(.:format)                        - Retrieve a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name(.:format)                        - Delete a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/clear(.:format)                  - Clear a feature
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/boolean(.:format)                - Boolean enable a feature
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/boolean(.:format)                - Boolean disable a feature
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/groups(.:format)                 - Enable Group
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/groups(.:format)                 - Disable Group
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/actors(.:format)                 - Enable Actor
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/actors(.:format)                 - Disable Actor
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_actors(.:format)   - Enable Percentage of Actors
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_actors(.:format)   - Disable Percentage of Actors
POST        /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_time(.:format)     - Enable Percentage of Time
DELETE      /api/:version/feature_flags/flipper/:project_id/features/:feature_name/percentage_of_time(.:format)     - Disable Percentage of Time
GET         /api/:version/feature_flags/flipper/:project_id/actors/:flipper_id(.:format)                            - Check if features are enabled for an actor

How to configure Flipper client

configuration = {
  url: 'http://gitlab.com/api/v4/feature_flags/flipper/<project-id>/', # required
  headers: {
      'instance_id' => '<gitlab-instance-id>',
      'environment' => '<gitlab-environment-name>'
  },
}

adapter = Flipper::Adapters::Http.new(configuration)
flipper = Flipper.new(adapter)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports