summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-05-31 21:06:01 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-05-31 21:06:01 +0000
commit671284ba375109becbfa2a288032cdc7301b157b (patch)
treefc055d19700f433115bbed4f62a86a72c711c56f /lib/api/entities.rb
parent322c9be816cd5cd9747a8737ec04622aa6b81e6b (diff)
downloadgitlab-ce-671284ba375109becbfa2a288032cdc7301b157b.tar.gz
Add feature toggles through Flipper
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index e10bd230ae2..fc8183a62c1 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -753,6 +753,28 @@ module API
expose :impersonation
end
+ class FeatureGate < Grape::Entity
+ expose :key
+ expose :value
+ end
+
+ class Feature < Grape::Entity
+ expose :name
+ expose :state
+ expose :gates, using: FeatureGate do |model|
+ model.gates.map do |gate|
+ value = model.gate_values[gate.key]
+
+ # By default all gate values are populated. Only show relevant ones.
+ if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?)
+ next
+ end
+
+ { key: gate.key, value: value }
+ end.compact
+ end
+ end
+
module JobRequest
class JobInfo < Grape::Entity
expose :name, :stage