diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-01 17:18:03 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-01 17:18:03 +0000 |
commit | 950db1bd6472813bb539b69a309402c4eb115122 (patch) | |
tree | 8a334eb48bcdd297ecd53c5152b82cc9dea112c3 /lib | |
parent | 7c17a4b32f39a1b0ac8c16dae27e7cc7d3bf3614 (diff) | |
parent | 7da88278c33d20d97cf0eabb76b3117219479d12 (diff) | |
download | gitlab-ce-950db1bd6472813bb539b69a309402c4eb115122.tar.gz |
Merge branch '24196-protected-variables' into 'master'
Implementation for protected variables
Closes #24196
See merge request !11688
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 1 | ||||
-rw-r--r-- | lib/api/variables.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/utils.rb | 8 |
3 files changed, 12 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e3258fdcffe..31da85e9917 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -675,6 +675,7 @@ module API class Variable < Grape::Entity expose :key, :value + expose :protected?, as: :protected end class Pipeline < PipelineBasic diff --git a/lib/api/variables.rb b/lib/api/variables.rb index 5acde41551b..381c4ef50b0 100644 --- a/lib/api/variables.rb +++ b/lib/api/variables.rb @@ -42,6 +42,7 @@ module API params do requires :key, type: String, desc: 'The key of the variable' requires :value, type: String, desc: 'The value of the variable' + optional :protected, type: String, desc: 'Whether the variable is protected' end post ':id/variables' do variable = user_project.variables.create(declared(params, include_parent_namespaces: false).to_h) @@ -59,13 +60,14 @@ module API params do optional :key, type: String, desc: 'The key of the variable' optional :value, type: String, desc: 'The value of the variable' + optional :protected, type: String, desc: 'Whether the variable is protected' end put ':id/variables/:key' do variable = user_project.variables.find_by(key: params[:key]) return not_found!('Variable') unless variable - if variable.update(value: params[:value]) + if variable.update(declared_params(include_missing: false).except(:key)) present variable, with: Entities::Variable else render_validation_error!(variable) diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index 4c395b4266e..fa182c4deda 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -21,5 +21,13 @@ module Gitlab nil end + + def boolean_to_yes_no(bool) + if bool + 'Yes' + else + 'No' + end + end end end |