debian-mirror-gitlab/lib/feature/shared.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.3 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# 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-11-24 15:15:51 +05:30
# default_enabled: defines a default state of a feature flag when created by `bin/feature-flag`
2021-01-03 14:25:43 +05:30
# ee_only: defines that a feature flag can only be created in a context of EE
2021-01-29 00:20:46 +05:30
# deprecated: defines if a feature flag type that is deprecated and to be removed,
# the deprecated types are hidden from all interfaces
2020-07-28 23:09:34 +05:30
# example: usage being shown when exception is raised
TYPES = {
development: {
description: 'Short lived, used to enable unfinished code to be deployed',
2021-01-03 14:25:43 +05:30
optional: false,
2020-07-28 23:09:34 +05:30
rollout_issue: true,
2021-01-03 14:25:43 +05:30
ee_only: false,
2020-11-24 15:15:51 +05:30
default_enabled: false,
2020-07-28 23:09:34 +05:30
example: <<-EOS
2020-11-24 15:15:51 +05:30
Feature.enabled?(:my_feature_flag, project)
Feature.enabled?(:my_feature_flag, project, type: :development)
2021-02-22 17:27:13 +05:30
push_frontend_feature_flag(:my_feature_flag, project)
2020-11-24 15:15:51 +05:30
EOS
},
ops: {
description: "Long-lived feature flags that control operational aspects of GitLab's behavior",
optional: true,
rollout_issue: false,
2021-01-03 14:25:43 +05:30
ee_only: false,
2020-11-24 15:15:51 +05:30
default_enabled: false,
example: <<-EOS
2021-02-22 17:27:13 +05:30
Feature.enabled?(:my_ops_flag, type: :ops)
push_frontend_feature_flag(:my_ops_flag, project, type: :ops)
2020-11-24 15:15:51 +05:30
EOS
},
2021-02-22 17:27:13 +05:30
experiment: {
description: 'Short lived, used specifically to run A/B/n experiments.',
optional: true,
rollout_issue: true,
2021-03-08 18:12:59 +05:30
ee_only: false,
2021-02-22 17:27:13 +05:30
default_enabled: false,
example: <<-EOS
experiment(:my_experiment, project: project, actor: current_user) { ...variant code... }
2021-03-08 18:12:59 +05:30
# or
Gitlab::Experimentation.in_experiment_group?(:my_experiment, subject: current_user)
2021-02-22 17:27:13 +05:30
EOS
2020-07-28 23:09:34 +05:30
}
}.freeze
2021-01-03 14:25:43 +05:30
# The ordering of PARAMS defines an order in YAML
# This is done to ease the file comparison
2020-07-28 23:09:34 +05:30
PARAMS = %i[
name
introduced_by_url
rollout_issue_url
2021-01-29 00:20:46 +05:30
milestone
2022-01-26 12:08:38 +05:30
log_state_changes
2021-01-03 14:25:43 +05:30
type
2020-07-28 23:09:34 +05:30
group
2021-01-03 14:25:43 +05:30
default_enabled
2020-07-28 23:09:34 +05:30
].freeze
end
end