Commit 255321ed authored by Ethan Reesor's avatar Ethan Reesor

Update Go proxy documentation

- Resolve discussions on !27746
- Document fetching private packages via `.netrc`
- Include required scope for API token
parent 709c5061
...@@ -13,7 +13,7 @@ The Packages feature allows GitLab to act as a repository for the following: ...@@ -13,7 +13,7 @@ The Packages feature allows GitLab to act as a repository for the following:
| [Conan Repository](../../user/packages/conan_repository/index.md) | The GitLab Conan Repository enables every project in GitLab to have its own space to store [Conan](https://conan.io/) packages. | 12.4+ | | [Conan Repository](../../user/packages/conan_repository/index.md) | The GitLab Conan Repository enables every project in GitLab to have its own space to store [Conan](https://conan.io/) packages. | 12.4+ |
| [Maven Repository](../../user/packages/maven_repository/index.md) | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | 11.3+ | | [Maven Repository](../../user/packages/maven_repository/index.md) | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | 11.3+ |
| [NPM Registry](../../user/packages/npm_registry/index.md) | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | | [NPM Registry](../../user/packages/npm_registry/index.md) | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ |
| [Go Proxy](../../user/packages/go_proxy/index.md) | The GitLab Go Proxy enables every project in GitLab to be fetched via the [Go proxy protocol](https://proxy.golang.org/). | ??.??+ | | [Go Proxy](../../user/packages/go_proxy/index.md) | The GitLab Go Proxy enables every project in GitLab to be fetched via the [Go proxy protocol](https://proxy.golang.org/). | 13.0+ |
Don't you see your package management system supported yet? Don't you see your package management system supported yet?
Please consider contributing Please consider contributing
......
# GitLab Go Proxy **(PREMIUM)** # GitLab Go Proxy **(PREMIUM)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/27376) in [GitLab Premium](https://about.gitlab.com/pricing/) ??.??. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/27376) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.0.
The GitLab Go Proxy implements the Go proxy protocol. The GitLab Go Proxy implements the Go proxy protocol.
...@@ -9,7 +9,7 @@ GitLab does not (yet) display Go modules in the **Packages** section of a ...@@ -9,7 +9,7 @@ GitLab does not (yet) display Go modules in the **Packages** section of a
project. Only the Go proxy protocol is supported at this time, and only for project. Only the Go proxy protocol is supported at this time, and only for
modules on GitLab. modules on GitLab.
## Enabling the Go proxy ## Enable the Go proxy
NOTE: **Note:** NOTE: **Note:**
This option is available only if your GitLab administrator has This option is available only if your GitLab administrator has
...@@ -25,7 +25,7 @@ by default. To enable it for existing projects, or if you want to disable it: ...@@ -25,7 +25,7 @@ by default. To enable it for existing projects, or if you want to disable it:
You should then be able to see the **Packages** section on the left sidebar. You should then be able to see the **Packages** section on the left sidebar.
Next, you must configure your development environment to use the Go proxy. Next, you must configure your development environment to use the Go proxy.
## Adding GitLab as a Go proxy ## Add GitLab as a Go proxy
NOTE: **Note:** NOTE: **Note:**
To use a Go proxy, you must be using Go 1.13 or later. To use a Go proxy, you must be using Go 1.13 or later.
...@@ -51,7 +51,40 @@ first go through GitLab. This can help avoid making requests for private ...@@ -51,7 +51,40 @@ first go through GitLab. This can help avoid making requests for private
packages to the public proxy, but `GOPRIVATE` is a much safer way of achieving packages to the public proxy, but `GOPRIVATE` is a much safer way of achieving
that. that.
## Releasing a module For example, with the following configuration, Go will attempt to fetch modules
from 1) GitLab project 1234's Go module proxy, 2) `proxy.golang.org`, and
finally 3) directly via VCS.
```shell
go env -w GOPROXY=https://gitlab.com/api/v4/projects/1234/packages/go,https://proxy.golang.org,direct
```
## Fetch modules from private projects
NOTE: **Note:**
`go` does not support transmitting credentials over insecure connections. The
steps below will only work if GitLab is configured for HTTPS.
GitLab's Go proxy implementation supports HTTP Basic authentication for personal
access tokens, in addition to the usual authentication mechanisms. To configure
Go to use HTTP Basic authentication, you must create a [personal access
token](../../profile/personal_access_tokens.md) with the `api` or `read_api`
scope and add it to [`~/.netrc`](https://ec.haxx.se/usingcurl/usingcurl-netrc):
```netrc
machine my-server
login my-user
password my-token
```
Replace `my-user` with your username and `my-token` with your personal access
token. The value of `my-server` should be `gitlab.com` or the URL of your GitLab
instance. You can optionally append a path to `my-server`, which will restrict
the scope that the credentials will be used for. For example, `machine
gitlab.com/my-group` will restrict the credentials to URLs starting with
`gitlab.com/my-group`.
## Release a module
NOTE: **Note:** NOTE: **Note:**
For a complete understanding of Go modules and versioning, see [this series of For a complete understanding of Go modules and versioning, see [this series of
...@@ -84,6 +117,6 @@ Tags that match the pseudo-version pattern are ignored, as otherwise they could ...@@ -84,6 +117,6 @@ Tags that match the pseudo-version pattern are ignored, as otherwise they could
interfere with fetching specific commits using a pseudo-version. Pseudo-versions interfere with fetching specific commits using a pseudo-version. Pseudo-versions
follow one of three formats: follow one of three formats:
- `vX.0.0-yyyymmddhhmmss-abcdefabcdef`, when no earlier tagged commit exists for X - `vX.0.0-yyyymmddhhmmss-abcdefabcdef`, when no earlier tagged commit exists for X.
- `vX.Y.Z-pre.0.yyyymmddhhmmss-abcdefabcdef`, when most recent prior tag is vX.Y.Z-pre - `vX.Y.Z-pre.0.yyyymmddhhmmss-abcdefabcdef`, when most recent prior tag is vX.Y.Z-pre.
- `vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdefabcdef`, when most recent prior tag is vX.Y.Z - `vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdefabcdef`, when most recent prior tag is vX.Y.Z.
...@@ -21,7 +21,7 @@ The Packages feature allows GitLab to act as a repository for the following: ...@@ -21,7 +21,7 @@ The Packages feature allows GitLab to act as a repository for the following:
| [NPM Registry](npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | | [NPM Registry](npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ |
| [NuGet Repository](nuget_repository/index.md) **(PREMIUM)** | The GitLab NuGet Repository will enable every project in GitLab to have its own space to store [NuGet](https://www.nuget.org/) packages. | 12.8+ | | [NuGet Repository](nuget_repository/index.md) **(PREMIUM)** | The GitLab NuGet Repository will enable every project in GitLab to have its own space to store [NuGet](https://www.nuget.org/) packages. | 12.8+ |
| [PyPi Repository](pypi_repository/index.md) **(PREMIUM)** | The GitLab PyPi Repository will enable every project in GitLab to have its own space to store [PyPi](https://pypi.org/) packages. | 12.10+ | | [PyPi Repository](pypi_repository/index.md) **(PREMIUM)** | The GitLab PyPi Repository will enable every project in GitLab to have its own space to store [PyPi](https://pypi.org/) packages. | 12.10+ |
| [Go Proxy](go_proxy/index.md) **(PREMIUM)** | The GitLab Go Proxy enables every project in GitLab to be fetched via the [Go proxy protocol](https://proxy.golang.org/). | ??.??+ | | [Go Proxy](go_proxy/index.md) **(PREMIUM)** | The GitLab Go Proxy enables every project in GitLab to be fetched via the [Go proxy protocol](https://proxy.golang.org/). | 13.0+ |
## Enable the Package Registry for your project ## Enable the Package Registry for your project
......
...@@ -114,7 +114,6 @@ module API ...@@ -114,7 +114,6 @@ module API
header['Content-Disposition'] = ActionDispatch::Http::ContentDisposition.format(disposition: 'attachment', filename: ver.name + '.zip') header['Content-Disposition'] = ActionDispatch::Http::ContentDisposition.format(disposition: 'attachment', filename: ver.name + '.zip')
header['Content-Transfer-Encoding'] = 'binary' header['Content-Transfer-Encoding'] = 'binary'
content_type 'text/plain' content_type 'text/plain'
# content_type 'application/zip'
status :ok status :ok
body ver.archive.string body ver.archive.string
end end
......
# frozen_string_literal: true # frozen_string_literal: true
def get_result(op, ret)
raise "#{op} failed: #{ret}" unless ret[:status] == :success
ret[:result]
end
FactoryBot.define do FactoryBot.define do
factory :go_module_commit, class: 'Commit' do factory :go_module_commit, class: 'Commit' do
skip_create skip_create
......
# frozen_string_literal: true # frozen_string_literal: true
def get_result(op, ret)
raise "#{op} failed: #{ret}" unless ret[:status] == :success
ret[:result]
end
FactoryBot.define do FactoryBot.define do
factory :go_module_version, class: 'Packages::GoModuleVersion' do factory :go_module_version, class: 'Packages::GoModuleVersion' do
skip_create skip_create
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment