Skip to content

Commit

Permalink
feat(go): Support GOPROXY (#9150)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored and rarkins committed Aug 17, 2021
1 parent 058f01b commit edbe6ae
Show file tree
Hide file tree
Showing 10 changed files with 844 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -726,6 +726,10 @@ Also, approval rules overriding should not be [prevented in GitLab settings](htt

Configuration added here applies for all Go-related updates, however currently the only supported package manager for Go is the native Go Modules (the `gomod` manager).

For self-hosted users, `GOPROXY`, `GONOPROXY` and `GOPRIVATE` environment variables are supported ([reference](https://golang.org/ref/mod#module-proxy)).

But when you use the `direct` or `off` keywords Renovate will fallback to its own fetching strategy (i.e. directly from GitHub, etc).

## group

Caution: Advanced functionality only. Do not use unless you know what you're doing.
Expand Down
10 changes: 10 additions & 0 deletions lib/datasource/go/__fixtures__/go-kit.list.txt
@@ -0,0 +1,10 @@
v0.7.0
v0.3.0
v0.8.0
v0.6.0
v0.10.0
v0.5.0
v0.9.0
v0.4.0
v0.1.0
v0.2.0
30 changes: 30 additions & 0 deletions lib/datasource/go/__snapshots__/goproxy.spec.ts.snap
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`datasource/go/goproxy requests listVersions 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/go-kit/kit/@v/list",
},
]
`;

exports[`datasource/go/goproxy requests versionInfo 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/go-kit/kit/@v/v0.5.0.info",
},
]
`;
240 changes: 240 additions & 0 deletions lib/datasource/go/__snapshots__/index.spec.ts.snap
Expand Up @@ -93,6 +93,246 @@ Array [
]
`;

exports[`datasource/go/index getReleases GOPROXY fetches release data from goproxy 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.0.info",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.1.info",
},
]
`;

exports[`datasource/go/index getReleases GOPROXY handles comma fallback 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "foo.example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://foo.example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "bar.example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://bar.example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.0.info",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.1.info",
},
]
`;

exports[`datasource/go/index getReleases GOPROXY handles pipe fallback 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.0.info",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.1.info",
},
]
`;

exports[`datasource/go/index getReleases GOPROXY handles timestamp fetch errors 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.0.info",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"host": "proxy.golang.org",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://proxy.golang.org/github.com/google/btree/@v/v1.0.1.info",
},
]
`;

exports[`datasource/go/index getReleases GOPROXY short-circuits with comma fallback 1`] = `
Array [
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "foo.example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://foo.example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "bar.example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://bar.example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept-encoding": "gzip, deflate, br",
"host": "baz.example.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://baz.example.com/github.com/google/btree/@v/list",
},
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate, br",
"host": "api.github.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://api.github.com/repos/google/btree/tags?per_page=100",
},
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate, br",
"host": "api.github.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://api.github.com/repos/google/btree/releases?per_page=100",
},
]
`;

exports[`datasource/go/index getReleases GOPROXY skips GONOPROXY and GOPRIVATE packages 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate, br",
"host": "api.github.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://api.github.com/repos/google/btree/tags?per_page=100",
},
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate, br",
"host": "api.github.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://api.github.com/repos/google/btree/releases?per_page=100",
},
]
`;

exports[`datasource/go/index getReleases handles fyne.io 1`] = `
Object {
"releases": Array [
Expand Down
10 changes: 10 additions & 0 deletions lib/datasource/go/common.ts
@@ -0,0 +1,10 @@
import { Http } from '../../util/http';

export const id = 'go';

export const http = new Http(id);

export enum GoproxyFallback {
WhenNotFoundOrGone = ',',
Always = '|',
}

0 comments on commit edbe6ae

Please sign in to comment.