2020-07-02 05:09:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This file can contain only simple constructs as it is shared between:
|
|
|
|
# 1. `Pure Ruby`: `bin/feature-flag`
|
|
|
|
# 2. `GitLab Rails`: `lib/feature/definition.rb`
|
|
|
|
|
|
|
|
class Feature
|
|
|
|
module Shared
|
|
|
|
# optional: defines if a on-disk definition is required for this feature flag type
|
|
|
|
# rollout_issue: defines if `bin/feature-flag` asks for rollout issue
|
2020-09-10 05:08:27 -04:00
|
|
|
# default_enabled: defines a default state of a feature flag when created by `bin/feature-flag`
|
2020-09-22 11:09:37 -04:00
|
|
|
# ee_only: defines that a feature flag can only be created in a context of EE
|
2020-10-28 08:08:40 -04:00
|
|
|
# deprecated: defines if a feature flag type that is deprecated and to be removed,
|
|
|
|
# the deprecated types are hidden from all interfaces
|
2020-07-02 05:09:00 -04:00
|
|
|
# example: usage being shown when exception is raised
|
|
|
|
TYPES = {
|
|
|
|
development: {
|
|
|
|
description: 'Short lived, used to enable unfinished code to be deployed',
|
2020-09-21 08:09:34 -04:00
|
|
|
optional: false,
|
2020-07-02 05:09:00 -04:00
|
|
|
rollout_issue: true,
|
2020-09-22 11:09:37 -04:00
|
|
|
ee_only: false,
|
2020-09-10 05:08:27 -04:00
|
|
|
default_enabled: false,
|
2020-07-02 05:09:00 -04:00
|
|
|
example: <<-EOS
|
2020-09-09 11:08:47 -04:00
|
|
|
Feature.enabled?(:my_feature_flag, project)
|
|
|
|
Feature.enabled?(:my_feature_flag, project, type: :development)
|
2020-12-10 19:09:41 -05:00
|
|
|
push_frontend_feature_flag(:my_feature_flag, project)
|
2020-09-09 11:08:47 -04:00
|
|
|
EOS
|
|
|
|
},
|
|
|
|
ops: {
|
|
|
|
description: "Long-lived feature flags that control operational aspects of GitLab's behavior",
|
2022-05-04 17:08:35 -04:00
|
|
|
optional: false,
|
|
|
|
rollout_issue: true,
|
2020-09-22 11:09:37 -04:00
|
|
|
ee_only: false,
|
2020-09-10 05:08:27 -04:00
|
|
|
default_enabled: false,
|
2020-09-09 11:08:47 -04:00
|
|
|
example: <<-EOS
|
2020-12-10 19:09:41 -05:00
|
|
|
Feature.enabled?(:my_ops_flag, type: :ops)
|
|
|
|
push_frontend_feature_flag(:my_ops_flag, project, type: :ops)
|
2020-07-02 05:09:00 -04:00
|
|
|
EOS
|
2020-09-10 05:08:27 -04:00
|
|
|
},
|
2022-05-04 17:08:35 -04:00
|
|
|
undefined: {
|
|
|
|
description: "Feature flags that are undefined in GitLab codebase (should not be used)",
|
|
|
|
optional: true,
|
|
|
|
rollout_issue: false,
|
|
|
|
ee_only: false,
|
|
|
|
default_enabled: false,
|
|
|
|
example: ''
|
|
|
|
},
|
2020-12-10 19:09:41 -05:00
|
|
|
experiment: {
|
|
|
|
description: 'Short lived, used specifically to run A/B/n experiments.',
|
|
|
|
optional: true,
|
|
|
|
rollout_issue: true,
|
2021-01-07 19:10:44 -05:00
|
|
|
ee_only: false,
|
2020-12-10 19:09:41 -05:00
|
|
|
default_enabled: false,
|
|
|
|
example: <<-EOS
|
|
|
|
experiment(:my_experiment, project: project, actor: current_user) { ...variant code... }
|
2021-01-07 19:10:44 -05:00
|
|
|
# or
|
|
|
|
Gitlab::Experimentation.in_experiment_group?(:my_experiment, subject: current_user)
|
2020-12-10 19:09:41 -05:00
|
|
|
EOS
|
2020-07-02 05:09:00 -04:00
|
|
|
}
|
|
|
|
}.freeze
|
|
|
|
|
2020-09-22 11:09:37 -04:00
|
|
|
# The ordering of PARAMS defines an order in YAML
|
|
|
|
# This is done to ease the file comparison
|
2020-07-02 05:09:00 -04:00
|
|
|
PARAMS = %i[
|
|
|
|
name
|
|
|
|
introduced_by_url
|
|
|
|
rollout_issue_url
|
2020-10-29 17:08:54 -04:00
|
|
|
milestone
|
2021-12-14 16:13:08 -05:00
|
|
|
log_state_changes
|
2020-09-21 08:09:34 -04:00
|
|
|
type
|
2020-07-02 05:09:00 -04:00
|
|
|
group
|
2020-09-21 08:09:34 -04:00
|
|
|
default_enabled
|
2020-07-02 05:09:00 -04:00
|
|
|
].freeze
|
|
|
|
end
|
|
|
|
end
|