summaryrefslogtreecommitdiff
path: root/lib/api/variables.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-03-04 14:50:15 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2019-03-04 17:44:57 +0100
commita7004e282586c2158fc13d5f82f210b4a63a7b92 (patch)
tree087dda6e96642b7fbfbbf6d408c35f71f58495c1 /lib/api/variables.rb
parent3f629b8d147b755a9303b67395372630aacbafb5 (diff)
downloadgitlab-ce-a7004e282586c2158fc13d5f82f210b4a63a7b92.tar.gz
Add method to API::Variables for filtering params
This allows EE to customize the parameters used in two places, without having to modify the source code directly.
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r--lib/api/variables.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index 148deb86c4c..d0d81ebc870 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -7,6 +7,14 @@ module API
before { authenticate! }
before { authorize! :admin_build, user_project }
+ helpers do
+ def filter_variable_parameters(params)
+ # This method exists so that EE can more easily filter out certain
+ # parameters, without having to modify the source code directly.
+ params
+ end
+ end
+
params do
requires :id, type: String, desc: 'The ID of a project'
end
@@ -50,6 +58,7 @@ module API
end
post ':id/variables' do
variable_params = declared_params(include_missing: false)
+ variable_params = filter_variable_parameters(variable_params)
variable = user_project.variables.create(variable_params)
@@ -75,6 +84,7 @@ module API
break not_found!('Variable') unless variable
variable_params = declared_params(include_missing: false).except(:key)
+ variable_params = filter_variable_parameters(variable_params)
if variable.update(variable_params)
present variable, with: Entities::Variable