summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:08:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:08:01 +0000
commit561e1b470f0a99fe6304c8f197348c47a637d594 (patch)
tree6b361b6b0b412b70450aca167079c50a13bd88d8 /lib/api
parent7b52c7cb634ef7047d30b0337fe477bcdcedf41d (diff)
downloadgitlab-ce-561e1b470f0a99fe6304c8f197348c47a637d594.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities/project.rb3
-rw-r--r--lib/api/helpers/projects_helpers.rb2
-rw-r--r--lib/api/lsif_data.rb6
-rw-r--r--lib/api/project_container_repositories.rb11
-rw-r--r--lib/api/projects.rb1
5 files changed, 20 insertions, 3 deletions
diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb
index 6ed2ed34360..85a00273192 100644
--- a/lib/api/entities/project.rb
+++ b/lib/api/entities/project.rb
@@ -106,6 +106,9 @@ module API
project.auto_devops.nil? ? 'continuous' : project.auto_devops.deploy_strategy
end
expose :autoclose_referenced_issues
+ expose :repository_storage, if: ->(project, options) {
+ Ability.allowed?(options[:current_user], :change_repository_storage, project)
+ }
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb
index c7c9f3ba077..85ed8a4d636 100644
--- a/lib/api/helpers/projects_helpers.rb
+++ b/lib/api/helpers/projects_helpers.rb
@@ -54,6 +54,7 @@ module API
optional :auto_devops_enabled, type: Boolean, desc: 'Flag indication if Auto DevOps is enabled'
optional :auto_devops_deploy_strategy, type: String, values: %w(continuous manual timed_incremental), desc: 'Auto Deploy strategy'
optional :autoclose_referenced_issues, type: Boolean, desc: 'Flag indication if referenced issues auto-closing is enabled'
+ optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins'
end
params :optional_project_params_ee do
@@ -125,6 +126,7 @@ module API
:wiki_access_level,
:avatar,
:suggestion_commit_message,
+ :repository_storage,
# TODO: remove in API v5, replaced by *_access_level
:issues_enabled,
diff --git a/lib/api/lsif_data.rb b/lib/api/lsif_data.rb
index 6513973133a..a673ccb4af0 100644
--- a/lib/api/lsif_data.rb
+++ b/lib/api/lsif_data.rb
@@ -15,7 +15,7 @@ module API
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/commits/:commit_id' do
params do
- requires :path, type: String, desc: 'The path of a file'
+ requires :paths, type: Array, desc: 'The paths of the files'
end
get 'lsif/info' do
authorize! :download_code, user_project
@@ -30,7 +30,9 @@ module API
authorize! :read_pipeline, artifact.job.pipeline
file_too_large! if artifact.file.cached_size > MAX_FILE_SIZE
- ::Projects::LsifDataService.new(artifact.file, @project, params).execute
+ service = ::Projects::LsifDataService.new(artifact.file, @project, params[:commit_id])
+
+ params[:paths].to_h { |path| [path, service.execute(path)] }
end
end
end
diff --git a/lib/api/project_container_repositories.rb b/lib/api/project_container_repositories.rb
index 70c913bea98..0fd887f4458 100644
--- a/lib/api/project_container_repositories.rb
+++ b/lib/api/project_container_repositories.rb
@@ -69,7 +69,16 @@ module API
end
params do
requires :repository_id, type: Integer, desc: 'The ID of the repository'
- requires :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
+ optional :name_regex_delete, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
+ # require either name_regex (deprecated) or name_regex_delete, it is ok to have both
+ given name_regex_delete: ->(val) { val.nil? } do
+ requires :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
+ end
+ optional :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
+ given name_regex: ->(val) { val.nil? } do
+ requires :name_regex_delete, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
+ end
+ optional :name_regex_keep, type: String, desc: 'The tag name regexp to retain'
optional :keep_n, type: Integer, desc: 'Keep n of latest tags with matching name'
optional :older_than, type: String, desc: 'Delete older than: 1h, 1d, 1month'
end
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 43d607bc0c1..f9d08881acf 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -25,6 +25,7 @@ module API
end
def verify_update_project_attrs!(project, attrs)
+ attrs.delete(:repository_storage) unless can?(current_user, :change_repository_storage, project)
end
def delete_project(user_project)