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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 04:45:44 +0300
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/uploaders
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/object_storage.rb46
-rw-r--r--app/uploaders/terraform/versioned_state_uploader.rb13
2 files changed, 55 insertions, 4 deletions
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index ac1f022c63f..d4c74ce277f 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -30,6 +30,8 @@ module ObjectStorage
REMOTE = 2
end
+ SUPPORTED_STORES = [Store::LOCAL, Store::REMOTE].freeze
+
module Extension
# this extension is the glue between the ObjectStorage::Concern and RecordsUploads::Concern
module RecordsUploads
@@ -178,10 +180,14 @@ module ObjectStorage
end
def workhorse_authorize(has_length:, maximum_size: nil)
- if self.object_store_enabled? && self.direct_upload_enabled?
- { RemoteObject: workhorse_remote_upload_options(has_length: has_length, maximum_size: maximum_size) }
- else
- { TempPath: workhorse_local_upload_path }
+ {}.tap do |hash|
+ if self.object_store_enabled? && self.direct_upload_enabled?
+ hash[:RemoteObject] = workhorse_remote_upload_options(has_length: has_length, maximum_size: maximum_size)
+ else
+ hash[:TempPath] = workhorse_local_upload_path
+ end
+
+ hash[:MaximumSize] = maximum_size if maximum_size.present?
end
end
@@ -206,6 +212,20 @@ module ObjectStorage
end
end
+ class OpenFile
+ extend Forwardable
+
+ # Explicitly exclude :path, because rubyzip uses that to detect "real" files.
+ def_delegators :@file, *(Zip::File::IO_METHODS - [:path])
+
+ # Even though :size is not in IO_METHODS, we do need it.
+ def_delegators :@file, :size
+
+ def initialize(file)
+ @file = file
+ end
+ end
+
# allow to configure and overwrite the filename
def filename
@filename || super || file&.filename # rubocop:disable Gitlab/ModuleWithInstanceVariables
@@ -255,6 +275,24 @@ module ObjectStorage
end
end
+ def use_open_file(&blk)
+ Tempfile.open(path) do |file|
+ file.unlink
+ file.binmode
+
+ if file_storage?
+ IO.copy_stream(path, file)
+ else
+ streamer = lambda { |chunk, _, _| file.write(chunk) }
+ Excon.get(url, response_block: streamer)
+ end
+
+ file.seek(0, IO::SEEK_SET)
+
+ yield OpenFile.new(file)
+ end
+ end
+
#
# Move the file to another store
#
diff --git a/app/uploaders/terraform/versioned_state_uploader.rb b/app/uploaders/terraform/versioned_state_uploader.rb
new file mode 100644
index 00000000000..be07993da0f
--- /dev/null
+++ b/app/uploaders/terraform/versioned_state_uploader.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Terraform
+ class VersionedStateUploader < StateUploader
+ def filename
+ "#{model.version}.tfstate"
+ end
+
+ def store_dir
+ Gitlab::HashedPath.new(model.uuid, root_hash: project_id)
+ end
+ end
+end