Skip to content

Create Packages::Go::Package class for golang packages

Dzmitry Meshcharakou requested to merge 435830-create-golang-package-class into master

Context

Step by step we want to complete the refactoring and extract every package format from Packages::Package to its own class.

What does this MR do and why?

This MR introduces Packages::Go::Package class for rubygems packages.

Go Proxy is in alpha https://docs.gitlab.com/ee/user/packages/go_proxy/

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.

How to set up and validate locally

Prerequisites

  1. Enable the feature flag

    Feature.enable(:go_proxy)
  2. Create a go module and push it to the repository.

    The steps to create a simple go module are described here

  3. Add a new tag to the project. For example v0.1.0

  4. Trigger the sync service in the rails console to create a new Go package.

    Packages::Go::SyncPackagesService.new(<project>, <tag_name>).execute_async

Verification

Since pulling the Go module requires HTTPS setup I listed the API endpoints that might be used to verify the changes using curl

module_name is equal to host + project's full path. For example: gdk.test/packages/greetings

  1. Get all tagged versions for a given Go module

    curl --header "Authorization: Bearer <PAT>" http://gdk.test:3000/api/v4/projects/<project_id>/packages/go/<module_name>/@v/list          

    The response should contain the module's version.

  2. Get all tagged versions for a given Go module

    curl --header "Authorization: Bearer <PAT>" http://gdk.test:3000/api/v4/projects/<project_id>/packages/go/<module_name>/@v/<version>.info

    The response should contain the module's version with a timestamp.

  3. Get the module file of a given module version

    curl --header "Authorization: Bearer <PAT>" http://gdk.test:3000/api/v4/projects/<project_id>/packages/go/<module_name>/@v/<version>.mod


    The response should contain the module's information.

  4. Get a zip of the source of the given module version

    curl --header "Authorization: Bearer <PAT>" http://gdk.test:3000/api/v4/projects/<project_id>/packages/go/<module_name>/@v/<version>.zip > mod.zip

    The mod.zip should contain the packed Go module.

Related to #435830 (closed)

Edited by Dzmitry Meshcharakou

Merge request reports