mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
feat(go)!: default GOPROXY (#20081)
Set default GOPROXY value to match `go`'s own default. Closes #20040 BREAKING CHANGE: Renovate will now use go's default `GOPROXY` settings. To avoid using the public proxy, configure `GOPROXY=direct`.
This commit is contained in:
parent
d28763fa01
commit
d92e19437a
5 changed files with 35 additions and 23 deletions
|
@ -53,25 +53,10 @@ describe('modules/datasource/go/index', () => {
|
||||||
delete process.env.GOPROXY;
|
delete process.env.GOPROXY;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fetches release info directly from VCS', async () => {
|
it('fetches releases', async () => {
|
||||||
const expected = { releases: [{ version: '0.0.1' }] };
|
|
||||||
getReleasesProxyMock.mockResolvedValue(null);
|
|
||||||
getReleasesDirectMock.mockResolvedValue(expected);
|
|
||||||
|
|
||||||
const res = await datasource.getReleases({
|
|
||||||
packageName: 'golang.org/foo/bar',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(res).toBe(expected);
|
|
||||||
expect(getReleasesProxyMock).not.toHaveBeenCalled();
|
|
||||||
expect(getReleasesDirectMock).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('supports GOPROXY', async () => {
|
|
||||||
const expected = { releases: [{ version: '0.0.1' }] };
|
const expected = { releases: [{ version: '0.0.1' }] };
|
||||||
getReleasesProxyMock.mockResolvedValue(expected);
|
getReleasesProxyMock.mockResolvedValue(expected);
|
||||||
getReleasesDirectMock.mockResolvedValue(null);
|
getReleasesDirectMock.mockResolvedValue(null);
|
||||||
process.env.GOPROXY = 'https://proxy.golang.org,direct';
|
|
||||||
|
|
||||||
const res = await datasource.getReleases({
|
const res = await datasource.getReleases({
|
||||||
packageName: 'golang.org/foo/bar',
|
packageName: 'golang.org/foo/bar',
|
||||||
|
|
|
@ -36,9 +36,7 @@ export class GoDatasource extends Datasource {
|
||||||
key: ({ packageName }: Partial<DigestConfig>) => `${packageName}-digest`,
|
key: ({ packageName }: Partial<DigestConfig>) => `${packageName}-digest`,
|
||||||
})
|
})
|
||||||
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
||||||
return process.env.GOPROXY
|
return this.goproxy.getReleases(config);
|
||||||
? this.goproxy.getReleases(config)
|
|
||||||
: this.direct.getReleases(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
5
lib/modules/datasource/go/readme.md
Normal file
5
lib/modules/datasource/go/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
This datasource will default to using the `GOPROXY` settings `https://proxy.golang.org,direct` if there is no value defined in environment variables.
|
||||||
|
|
||||||
|
To override this default and use a different proxy, simply configure `GOPROXY` to an alternative setting in env.
|
||||||
|
|
||||||
|
To override this default and stop using any proxy at all, set `GOPROXY` to the value `direct`.
|
|
@ -285,6 +285,30 @@ describe('modules/datasource/go/releases-goproxy', () => {
|
||||||
delete process.env.GOINSECURE;
|
delete process.env.GOINSECURE;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles direct', async () => {
|
||||||
|
process.env.GOPROXY = 'direct';
|
||||||
|
|
||||||
|
githubGetTags.mockResolvedValueOnce({
|
||||||
|
releases: [
|
||||||
|
{ gitRef: 'v1.0.0', version: 'v1.0.0' },
|
||||||
|
{ gitRef: 'v1.0.1', version: 'v1.0.1' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
githubGetReleases.mockResolvedValueOnce({ releases: [] });
|
||||||
|
|
||||||
|
const res = await datasource.getReleases({
|
||||||
|
packageName: 'github.com/google/btree',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res).toEqual({
|
||||||
|
releases: [
|
||||||
|
{ gitRef: 'v1.0.0', version: 'v1.0.0' },
|
||||||
|
{ gitRef: 'v1.0.1', version: 'v1.0.1' },
|
||||||
|
],
|
||||||
|
sourceUrl: 'https://github.com/google/btree',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('skips GONOPROXY and GOPRIVATE packages', async () => {
|
it('skips GONOPROXY and GOPRIVATE packages', async () => {
|
||||||
process.env.GOPROXY = baseUrl;
|
process.env.GOPROXY = baseUrl;
|
||||||
process.env.GOPRIVATE = 'github.com/google/*';
|
process.env.GOPRIVATE = 'github.com/google/*';
|
||||||
|
@ -311,8 +335,6 @@ describe('modules/datasource/go/releases-goproxy', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fetches release data from goproxy', async () => {
|
it('fetches release data from goproxy', async () => {
|
||||||
process.env.GOPROXY = baseUrl;
|
|
||||||
|
|
||||||
httpMock
|
httpMock
|
||||||
.scope(`${baseUrl}/github.com/google/btree`)
|
.scope(`${baseUrl}/github.com/google/btree`)
|
||||||
.get('/@v/list')
|
.get('/@v/list')
|
||||||
|
|
|
@ -32,8 +32,10 @@ export class GoProxyDatasource extends Datasource {
|
||||||
async getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
async getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
||||||
const { packageName } = config;
|
const { packageName } = config;
|
||||||
logger.trace(`goproxy.getReleases(${packageName})`);
|
logger.trace(`goproxy.getReleases(${packageName})`);
|
||||||
|
const goproxy = process.env.GOPROXY ?? 'https://proxy.golang.org,direct';
|
||||||
const goproxy = process.env.GOPROXY;
|
if (goproxy === 'direct') {
|
||||||
|
return this.direct.getReleases(config);
|
||||||
|
}
|
||||||
const proxyList = this.parseGoproxy(goproxy);
|
const proxyList = this.parseGoproxy(goproxy);
|
||||||
const noproxy = GoProxyDatasource.parseNoproxy();
|
const noproxy = GoProxyDatasource.parseNoproxy();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue