summaryrefslogtreecommitdiff
path: root/lib/feature/shared.rb
blob: c06f699ef2735be8df481e5963486e1115362a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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
    # default_enabled: defines a default state of a feature flag when created by `bin/feature-flag`
    # example: usage being shown when exception is raised
    TYPES = {
      development: {
        description: 'Short lived, used to enable unfinished code to be deployed',
        optional: true,
        rollout_issue: true,
        default_enabled: false,
        example: <<-EOS
          Feature.enabled?(:my_feature_flag, project)
          Feature.enabled?(:my_feature_flag, project, type: :development)
          push_frontend_feature_flag?(:my_feature_flag, project)
        EOS
      },
      ops: {
        description: "Long-lived feature flags that control operational aspects of GitLab's behavior",
        optional: true,
        rollout_issue: false,
        default_enabled: false,
        example: <<-EOS
          Feature.enabled?(:my_ops_flag, type: ops)
          push_frontend_feature_flag?(:my_ops_flag, project, type: :ops)
        EOS
      },
      licensed: {
        description: 'Permanent feature flags used to temporarily disable licensed features.',
        optional: true,
        rollout_issue: false,
        default_enabled: true,
        example: <<-EOS
          project.feature_available?(:my_licensed_feature)
          namespace.feature_available?(:my_licensed_feature)
        EOS
      }
    }.freeze

    PARAMS = %i[
      name
      default_enabled
      type
      introduced_by_url
      rollout_issue_url
      group
    ].freeze
  end
end