summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 09:09:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 09:09:46 +0000
commit221b529789f4090341a825695aeb49b8df6dd11d (patch)
treec8843e4ca5ef1034752eb68712fcf338b24950db /lib
parent00a8c64ffd18e74df4b1cdeda7776b5221fddafe (diff)
downloadgitlab-ce-221b529789f4090341a825695aeb49b8df6dd11d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/users.rb3
-rw-r--r--lib/container_registry/client.rb10
-rw-r--r--lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml2
-rw-r--r--lib/gitlab/static_site_editor/config.rb26
4 files changed, 31 insertions, 10 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 1694f3fe3fb..c986414c223 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -82,6 +82,7 @@ module API
optional :blocked, type: Boolean, default: false, desc: 'Filters only blocked users'
optional :created_after, type: DateTime, desc: 'Return users created after the specified time'
optional :created_before, type: DateTime, desc: 'Return users created before the specified time'
+ optional :without_projects, type: Boolean, default: false, desc: 'Filters only users without projects'
all_or_none_of :extern_uid, :provider
use :sort_params
@@ -94,7 +95,7 @@ module API
authenticated_as_admin! if params[:external].present? || (params[:extern_uid].present? && params[:provider].present?)
unless current_user&.admin?
- params.except!(:created_after, :created_before, :order_by, :sort, :two_factor)
+ params.except!(:created_after, :created_before, :order_by, :sort, :two_factor, :without_projects)
end
users = UsersFinder.new(current_user, params).execute
diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb
index 12f7f04634f..56f556c229a 100644
--- a/lib/container_registry/client.rb
+++ b/lib/container_registry/client.rb
@@ -159,13 +159,13 @@ module ContainerRegistry
end
def faraday
- @faraday ||= Faraday.new(@base_uri) do |conn|
+ @faraday ||= faraday_base do |conn|
initialize_connection(conn, @options, &method(:accept_manifest))
end
end
def faraday_blob
- @faraday_blob ||= Faraday.new(@base_uri) do |conn|
+ @faraday_blob ||= faraday_base do |conn|
initialize_connection(conn, @options)
end
end
@@ -173,12 +173,16 @@ module ContainerRegistry
# Create a new request to make sure the Authorization header is not inserted
# via the Faraday middleware
def faraday_redirect
- @faraday_redirect ||= Faraday.new(@base_uri) do |conn|
+ @faraday_redirect ||= faraday_base do |conn|
conn.request :json
conn.adapter :net_http
end
end
+ def faraday_base(&block)
+ Faraday.new(@base_uri, headers: { user_agent: "GitLab/#{Gitlab::VERSION}" }, &block)
+ end
+
def delete_if_exists(path)
result = faraday.delete(path)
diff --git a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
index ecca1731579..a41b399032f 100644
--- a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
@@ -9,7 +9,7 @@ include:
- template: Jobs/Build.gitlab-ci.yml
.deploy_to_ecs:
- image: registry.gitlab.com/gitlab-org/cloud-deploy:latest
+ image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest
script:
- ecs update-task-definition
diff --git a/lib/gitlab/static_site_editor/config.rb b/lib/gitlab/static_site_editor/config.rb
index 4bc0fc95abd..41d54ee0a92 100644
--- a/lib/gitlab/static_site_editor/config.rb
+++ b/lib/gitlab/static_site_editor/config.rb
@@ -3,33 +3,49 @@
module Gitlab
module StaticSiteEditor
class Config
+ SUPPORTED_EXTENSIONS = %w[.md].freeze
+
def initialize(repository, ref, file_path, return_url)
@repository = repository
@ref = ref
@file_path = file_path
@return_url = return_url
+ @commit_id = repository.commit(ref)&.id if ref
end
def payload
{
branch: ref,
path: file_path,
- commit: commit.id,
+ commit_id: commit_id,
project_id: project.id,
project: project.path,
namespace: project.namespace.path,
- return_url: return_url
+ return_url: return_url,
+ is_supported_content: supported_content?
}
end
private
- attr_reader :repository, :ref, :file_path, :return_url
+ attr_reader :repository, :ref, :file_path, :return_url, :commit_id
delegate :project, to: :repository
- def commit
- repository.commit(ref)
+ def supported_content?
+ master_branch? && extension_supported? && file_exists?
+ end
+
+ def master_branch?
+ ref == 'master'
+ end
+
+ def extension_supported?
+ File.extname(file_path).in?(SUPPORTED_EXTENSIONS)
+ end
+
+ def file_exists?
+ commit_id.present? && repository.blob_at(commit_id, file_path).present?
end
end
end