summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 18:42:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 18:42:02 +0000
commit5a1541a44f745cf9ae4121d6919a1530a7212afe (patch)
tree3841ea24d9eaa1e5521f168348af3fd409aab962 /lib
parentf1bc6c9f752e5dcf11f5798c70498e9ae4a8e3ec (diff)
downloadgitlab-ce-5a1541a44f745cf9ae4121d6919a1530a7212afe.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/api/lint.rb2
-rw-r--r--lib/gitlab/current_settings.rb4
-rw-r--r--lib/gitlab/import_export/repo_restorer.rb2
-rw-r--r--lib/gitlab/template/base_template.rb2
-rw-r--r--lib/gitlab/template/issue_template.rb2
-rw-r--r--lib/gitlab/template/merge_request_template.rb2
-rw-r--r--lib/object_storage/config.rb36
-rw-r--r--lib/object_storage/direct_upload.rb4
8 files changed, 11 insertions, 43 deletions
diff --git a/lib/api/lint.rb b/lib/api/lint.rb
index 2d30754a36d..e0806674c6a 100644
--- a/lib/api/lint.rb
+++ b/lib/api/lint.rb
@@ -11,7 +11,7 @@ module API
optional :include_merged_yaml, type: Boolean, desc: 'Whether or not to include merged CI config yaml in the response'
end
post '/lint' do
- unauthorized! unless Gitlab::CurrentSettings.signup_enabled? && current_user
+ unauthorized! if Gitlab::CurrentSettings.signup_disabled? && current_user.nil?
result = Gitlab::Ci::YamlProcessor.new(params[:content], user: current_user).execute
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 0bf41f9dc0d..55f381fcb64 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -3,6 +3,10 @@
module Gitlab
module CurrentSettings
class << self
+ def signup_disabled?
+ !signup_enabled?
+ end
+
def current_application_settings
Gitlab::SafeRequestStore.fetch(:current_application_settings) { ensure_application_settings! }
end
diff --git a/lib/gitlab/import_export/repo_restorer.rb b/lib/gitlab/import_export/repo_restorer.rb
index 8af7b68d78e..998da3e4afb 100644
--- a/lib/gitlab/import_export/repo_restorer.rb
+++ b/lib/gitlab/import_export/repo_restorer.rb
@@ -42,7 +42,7 @@ module Gitlab
def ensure_repository_does_not_exist!
if repository.exists?
shared.logger.info(
- message: %Q{Deleting existing "#{repository.path}" to re-import it.}
+ message: %Q{Deleting existing "#{repository.disk_path}" to re-import it.}
)
Repositories::DestroyService.new(repository).execute
diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb
index 0f933a61598..3be77aff07e 100644
--- a/lib/gitlab/template/base_template.rb
+++ b/lib/gitlab/template/base_template.rb
@@ -108,7 +108,7 @@ module Gitlab
# Gitaly the actual template names within a given project's repository for all file templates
# other than `issue` and `merge request` description templates, which would instead
# overwrite the `template_names` method to return a redis cached version, by reading cached values
- # from `repository.issue_template_names_by_category` and `repository.merge_request_template_names_by_category`
+ # from `repository.issue_template_names_hash` and `repository.merge_request_template_names_hash`
# methods.
def repository_template_names(project)
template_names_by_category(self.all(project))
diff --git a/lib/gitlab/template/issue_template.rb b/lib/gitlab/template/issue_template.rb
index 3049f43b322..30fff9bdae9 100644
--- a/lib/gitlab/template/issue_template.rb
+++ b/lib/gitlab/template/issue_template.rb
@@ -23,7 +23,7 @@ module Gitlab
# own caching mechanism to avoid the back and forth call jumps between finder and model.
#
# follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/300279
- project.repository.issue_template_names_by_category
+ project.repository.issue_template_names_hash
end
end
end
diff --git a/lib/gitlab/template/merge_request_template.rb b/lib/gitlab/template/merge_request_template.rb
index 9442f3b13fb..7491c8f26c6 100644
--- a/lib/gitlab/template/merge_request_template.rb
+++ b/lib/gitlab/template/merge_request_template.rb
@@ -23,7 +23,7 @@ module Gitlab
# own caching mechanism to avoid the back and forth call jumps between finder and model.
#
# follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/300279
- project.repository.merge_request_template_names_by_category
+ project.repository.merge_request_template_names_hash
end
end
end
diff --git a/lib/object_storage/config.rb b/lib/object_storage/config.rb
index 0e6408b4917..f933d4e4866 100644
--- a/lib/object_storage/config.rb
+++ b/lib/object_storage/config.rb
@@ -2,8 +2,6 @@
module ObjectStorage
class Config
- include Gitlab::Utils::StrongMemoize
-
AWS_PROVIDER = 'AWS'
AZURE_PROVIDER = 'AzureRM'
GOOGLE_PROVIDER = 'Google'
@@ -68,36 +66,6 @@ module ObjectStorage
def provider
credentials[:provider].to_s
end
-
- # This method converts fog-aws parameters to an endpoint for the
- # Workhorse S3 client.
- def s3_endpoint
- strong_memoize(:s3_endpoint) do
- # We could omit this line and let the following code handle this, but
- # this will ensure that working configurations that use `endpoint`
- # will continue to work.
- next credentials[:endpoint] if credentials[:endpoint].present?
-
- generate_s3_endpoint_from_credentials
- end
- end
-
- def generate_s3_endpoint_from_credentials
- # fog-aws has special handling of the host, region, scheme, etc:
- # https://github.com/fog/fog-aws/blob/c7a11ba377a76d147861d0e921eb1e245bc11b6c/lib/fog/aws/storage.rb#L440-L449
- # Rather than reimplement this, we derive it from a sample GET URL.
- url = fog_connection.get_object_url(bucket, "tmp", nil)
- uri = ::Addressable::URI.parse(url)
-
- return unless uri&.scheme && uri&.host
-
- endpoint = "#{uri.scheme}://#{uri.host}"
- endpoint += ":#{uri.port}" if uri.port
- endpoint
- rescue ::URI::InvalidComponentError, ::Addressable::URI::InvalidURIError => e
- Gitlab::ErrorTracking.track_exception(e)
- nil
- end
# End AWS-specific options
# Begin Azure-specific options
@@ -123,10 +91,6 @@ module ObjectStorage
end
end
- def fog_connection
- @connection ||= ::Fog::Storage.new(credentials)
- end
-
private
# This returns a Hash of HTTP encryption headers to send along to S3.
diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb
index 9fb4b571e06..7f1c30e574d 100644
--- a/lib/object_storage/direct_upload.rb
+++ b/lib/object_storage/direct_upload.rb
@@ -80,7 +80,7 @@ module ObjectStorage
S3Config: {
Bucket: bucket_name,
Region: credentials[:region],
- Endpoint: config.s3_endpoint,
+ Endpoint: credentials[:endpoint],
PathStyle: config.use_path_style?,
UseIamProfile: config.use_iam_profile?,
ServerSideEncryption: config.server_side_encryption,
@@ -229,7 +229,7 @@ module ObjectStorage
end
def connection
- config.fog_connection
+ @connection ||= ::Fog::Storage.new(credentials)
end
end
end