summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/external/file/local.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config/external/file/local.rb')
-rw-r--r--lib/gitlab/ci/config/external/file/local.rb26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/gitlab/ci/config/external/file/local.rb b/lib/gitlab/ci/config/external/file/local.rb
index 0912a732158..bb1c304d02b 100644
--- a/lib/gitlab/ci/config/external/file/local.rb
+++ b/lib/gitlab/ci/config/external/file/local.rb
@@ -10,7 +10,8 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
def initialize(params, context)
- @location = params[:local]
+ # `Repository#blobs_at` does not support files with the `/` prefix.
+ @location = Gitlab::Utils.remove_leading_slashes(params[:local])
super
end
@@ -29,8 +30,6 @@ module Gitlab
)
end
- private
-
def validate_context!
return if context.project&.repository
@@ -45,14 +44,19 @@ module Gitlab
end
end
+ private
+
def fetch_local_content
- context.logger.instrument(:config_file_fetch_local_content) do
- context.project.repository.blob_data_at(context.sha, location)
+ BatchLoader.for([context.sha, location])
+ .batch(key: context.project) do |locations, loader, args|
+ context.logger.instrument(:config_file_fetch_local_content) do
+ args[:key].repository.blobs_at(locations).each do |blob|
+ loader.call([blob.commit_id, blob.path], blob.data)
+ end
+ end
+ rescue GRPC::InvalidArgument
+ # no-op
end
- rescue GRPC::InvalidArgument
- errors.push("Sha #{context.sha} is not valid!")
-
- nil
end
override :expand_context_attrs
@@ -67,6 +71,8 @@ module Gitlab
end
def masked_blob
+ return unless valid?
+
strong_memoize(:masked_blob) do
context.mask_variables_from(
Gitlab::Routing.url_helpers.project_blob_url(context.project, ::File.join(context.sha, location))
@@ -75,7 +81,7 @@ module Gitlab
end
def masked_raw
- return unless context.project
+ return unless valid?
strong_memoize(:masked_raw) do
context.mask_variables_from(