Extract generic Packages::MetadataCacheUploader

📖 Context

We introduced Packages::Npm::MetadataCacheUploader for NPM metadata cache, this uploader is mainly responsible for providing the functions that would be used by carrierwave to get the object storage keys.

As part of Helm metadata cache, we also introduce Packages::Helm::MetadataCaccheUploader, and the only difference between these 2 uploaders is the FILENAME.

What does this MR do?

In order to reduce the duplicated code, this MR added a generic uploader Packages::MetadataCacheUploader, this uploader will contain all the shared functions and be used by the other metadata cache uploaders.

👉🏻 References

Screenshots or screen recordings

N/A

How to set up and validate locally

Note: We will only validate whether Packages::Npm::MetadataCaccheUploader is working since Packages::Helm::MetadataCache is not used yet.

  1. Switch to this branch 555047-extract-generic-metadata-cache-uploader
  2. Ensure object_store is enabled with gdk
  3. Setup TOKEN, GITLAB_URL and PROJECT_ID in your terminal
  4. In rails console, ry to create NPM metadata cache
    # find a npm package
    package = Packages::Package.where(package_type: 'npm').last
    
    project = package.project
    package_name = package.name
    
    # check current metadata cache, destroy it if exists
    project.npm_metadata_caches.destroy_all
    project.reload
    
    # invoke service to create/update metadata cache
    ::Packages::Npm::CreateMetadataCacheService.new(project, package_name).execute
    
    # check npm metadata cache again, the record should be created
    project.npm_metadata_caches

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #555047 (closed)

Edited by Sylvia Shen

Merge request reports

Loading