Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/uploaders/object_storage/cdn.rb')
-rw-r--r--app/uploaders/object_storage/cdn.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/uploaders/object_storage/cdn.rb b/app/uploaders/object_storage/cdn.rb
index 0711ab0bd28..e49e2780147 100644
--- a/app/uploaders/object_storage/cdn.rb
+++ b/app/uploaders/object_storage/cdn.rb
@@ -10,6 +10,16 @@ module ObjectStorage
include Gitlab::Utils::StrongMemoize
+ UrlResult = Struct.new(:url, :used_cdn)
+
+ def cdn_enabled_url(project, ip_address)
+ if Feature.enabled?(:ci_job_artifacts_cdn, project) && use_cdn?(ip_address)
+ UrlResult.new(cdn_signed_url, true)
+ else
+ UrlResult.new(url, false)
+ end
+ end
+
def use_cdn?(request_ip)
return false unless cdn_options.is_a?(Hash) && cdn_options['provider']
return false unless cdn_provider