Skip to content

Extract common parts of the Maven dependency proxy

David Fernandez requested to merge 435644-extract-dependency-proxy-logic into master

😎 Context

In Maven dependency proxy (&3610 - closed), we implemented and delivered the Maven dependency proxy. Read about it here: https://docs.gitlab.com/ee/user/packages/package_registry/dependency_proxy/.

We are now starting working on npm dependency proxy (&3608) which is exactly the same features set (GitLab acting as a pull through cache) but for the NPM package format.

The Maven dependency proxy has some interactions with the Package Registry as it uses it as a cache location (see https://docs.gitlab.com/ee/user/packages/package_registry/dependency_proxy/#advanced-caching). This is the core behavior of the dependency proxy for packages that we will need to implement for NPM.

To avoid a massive code duplication, in this MR, we're going to extract all the common logic that will be used by both dependency proxies.

This is preparatory work for the implementation of NPM dependency proxy: implement the download tg... (#435644 - closed) and later.

If you're interested to see these changes + the first step for the NPM proxy, see NPM dependency proxy tgz download file endpoint (!144320 - merged). If we look at the ee/lib/api/dependency_proxy/packages/npm.rb, we only need 100 lines to implement the first endpoint of the NPM dependency proxy 😻

🔍 What does this MR do and why?

  • Extract the Maven dependency proxy caching logic into helper functions.
  • Update the tracking events so that they adapt to the considered package format.
  • Move the DependencyProxy::Packages::Maven::VerifyPackageFileEtagService to DependencyProxy::Packages::VerifyPackageFileEtagService as this service is part of the caching logic and is not really tied to a package format (and we're going to use for NPM too).
    • Move the related specs.

No changelog here as this is a pure code extract with no impact on the existing Maven dependency proxy behaviors. If there is an impact, that will be considered as a typebug.

We are quite confident in this refactoring as the maven dependency proxy is covered by a pretty large requests spec and a feature spec (which also checks all the 🏓 s done with workhorse).

🏎 MR acceptance checklist

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

📺 Screenshots or screen recordings

No changes in the UI 🦄

How to set up and validate locally

Follow https://docs.gitlab.com/ee/user/packages/package_registry/dependency_proxy/

Edited by David Fernandez

Merge request reports