diff options
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/packages/composer/cache_uploader.rb | 26 | ||||
-rw-r--r-- | app/uploaders/packages/debian/component_file_uploader.rb | 27 | ||||
-rw-r--r-- | app/uploaders/terraform/state_uploader.rb | 4 |
3 files changed, 57 insertions, 0 deletions
diff --git a/app/uploaders/packages/composer/cache_uploader.rb b/app/uploaders/packages/composer/cache_uploader.rb new file mode 100644 index 00000000000..f8052ec4810 --- /dev/null +++ b/app/uploaders/packages/composer/cache_uploader.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +class Packages::Composer::CacheUploader < GitlabUploader + include ObjectStorage::Concern + + storage_options Gitlab.config.packages + + after :store, :schedule_background_upload + + alias_method :upload, :model + + def filename + "#{model.file_sha256}.json" + end + + def store_dir + dynamic_segment + end + + private + + def dynamic_segment + raise ObjectNotReadyError, 'Package model not ready' unless model.id + + Gitlab::HashedPath.new("packages", "composer_cache", model.namespace_id, root_hash: model.namespace_id) + end +end diff --git a/app/uploaders/packages/debian/component_file_uploader.rb b/app/uploaders/packages/debian/component_file_uploader.rb new file mode 100644 index 00000000000..e4d637fecac --- /dev/null +++ b/app/uploaders/packages/debian/component_file_uploader.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +class Packages::Debian::ComponentFileUploader < GitlabUploader + extend Workhorse::UploadPath + include ObjectStorage::Concern + + storage_options Gitlab.config.packages + + after :store, :schedule_background_upload + + alias_method :upload, :model + + def filename + model.file_name + end + + def store_dir + dynamic_segment + end + + private + + def dynamic_segment + raise ObjectNotReadyError, 'Package model not ready' unless model.id && model.component.distribution.container_id + + Gitlab::HashedPath.new("debian_#{model.class.container_type}_component_file", model.id, root_hash: model.component.distribution.container_id) + end +end diff --git a/app/uploaders/terraform/state_uploader.rb b/app/uploaders/terraform/state_uploader.rb index d80725cb051..091b253b0ed 100644 --- a/app/uploaders/terraform/state_uploader.rb +++ b/app/uploaders/terraform/state_uploader.rb @@ -6,6 +6,10 @@ module Terraform storage_options Gitlab.config.terraform_state + # TODO: Remove this line + # See https://gitlab.com/gitlab-org/gitlab/-/issues/232917 + alias_method :upload, :model + delegate :terraform_state, :project_id, to: :model # Use Lockbox to encrypt/decrypt the stored file (registers CarrierWave callbacks) |