diff options
-rw-r--r-- | app/controllers/groups/variables_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/variables_controller.rb | 7 | ||||
-rw-r--r-- | app/models/ci/group_variable.rb | 3 | ||||
-rw-r--r-- | app/models/ci/variable.rb | 3 |
4 files changed, 8 insertions, 12 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index 2794d5fe6ec..91e394c8ce8 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -35,12 +35,7 @@ module Groups end def group_variables_params - filtered_params = params.permit(variables_attributes: [*variable_params_attributes]) - filtered_params["variables_attributes"].each do |variable| - variable["key"] = variable.delete("secret_key") - variable["value"] = variable.delete("secret_value") - end - filtered_params + params.permit(variables_attributes: [*variable_params_attributes]) end def variable_params_attributes diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 3cbfe7b3cc1..ffe93522ca6 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -32,12 +32,7 @@ class Projects::VariablesController < Projects::ApplicationController end def variables_params - filtered_params = params.permit(variables_attributes: [*variable_params_attributes]) - filtered_params["variables_attributes"].each do |variable| - variable["key"] = variable.delete("secret_key") - variable["value"] = variable.delete("secret_value") - end - filtered_params + params.permit(variables_attributes: [*variable_params_attributes]) end def variable_params_attributes diff --git a/app/models/ci/group_variable.rb b/app/models/ci/group_variable.rb index 1dd0e050ba9..65399557289 100644 --- a/app/models/ci/group_variable.rb +++ b/app/models/ci/group_variable.rb @@ -6,6 +6,9 @@ module Ci belongs_to :group + alias_attribute :secret_key, :key + alias_attribute :secret_value, :value + validates :key, uniqueness: { scope: :group_id, message: "(%{value}) has already been taken" diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb index 7c71291de84..bcad55f115f 100644 --- a/app/models/ci/variable.rb +++ b/app/models/ci/variable.rb @@ -6,6 +6,9 @@ module Ci belongs_to :project + alias_attribute :secret_key, :key + alias_attribute :secret_value, :value + validates :key, uniqueness: { scope: [:project_id, :environment_scope], message: "(%{value}) has already been taken" |