mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: add http2 option (#6957)
This commit is contained in:
parent
d8157a7944
commit
bbea59939e
5 changed files with 54 additions and 0 deletions
|
@ -572,6 +572,10 @@ Renovate does not do a "longest match" algorithm to pick between multiple matchi
|
||||||
|
|
||||||
If you have any uncertainty about exactly which hosts a service uses, then it can be more reliable to use `domainName` instead of `hostName` or `baseUrl`. e.g. configure `"hostName": "docker.io"` to cover both `index.docker.io` and `auth.docker.io` and any other host that's in use.
|
If you have any uncertainty about exactly which hosts a service uses, then it can be more reliable to use `domainName` instead of `hostName` or `baseUrl`. e.g. configure `"hostName": "docker.io"` to cover both `index.docker.io` and `auth.docker.io` and any other host that's in use.
|
||||||
|
|
||||||
|
### enableHttp2
|
||||||
|
|
||||||
|
Enable got [http2](https://github.com/sindresorhus/got/blob/v11.5.2/readme.md#http2) support.
|
||||||
|
|
||||||
### hostName
|
### hostName
|
||||||
|
|
||||||
### hostType
|
### hostType
|
||||||
|
|
|
@ -1666,6 +1666,16 @@ const options: RenovateOptions[] = [
|
||||||
cli: false,
|
cli: false,
|
||||||
env: false,
|
env: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'enableHttp2',
|
||||||
|
description: 'Enable got http2 support.',
|
||||||
|
type: 'boolean',
|
||||||
|
stage: 'repository',
|
||||||
|
parent: 'hostRules',
|
||||||
|
default: false,
|
||||||
|
cli: false,
|
||||||
|
env: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'prBodyDefinitions',
|
name: 'prBodyDefinitions',
|
||||||
description: 'Table column definitions for use in PR tables',
|
description: 'Table column definitions for use in PR tables',
|
||||||
|
|
|
@ -16,4 +16,5 @@ export interface HostRule {
|
||||||
abortOnError?: boolean;
|
abortOnError?: boolean;
|
||||||
abortIgnoreStatusCodes?: number[];
|
abortIgnoreStatusCodes?: number[];
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
enableHttp2?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,14 @@ import {
|
||||||
PLATFORM_TYPE_GITEA,
|
PLATFORM_TYPE_GITEA,
|
||||||
PLATFORM_TYPE_GITHUB,
|
PLATFORM_TYPE_GITHUB,
|
||||||
} from '../../constants/platforms';
|
} from '../../constants/platforms';
|
||||||
|
import { bootstrap } from '../../proxy';
|
||||||
import * as hostRules from '../host-rules';
|
import * as hostRules from '../host-rules';
|
||||||
import { applyHostRules } from './host-rules';
|
import { applyHostRules } from './host-rules';
|
||||||
|
|
||||||
const url = 'https://github.com';
|
const url = 'https://github.com';
|
||||||
|
|
||||||
|
jest.mock('global-agent');
|
||||||
|
|
||||||
describe(getName(__filename), () => {
|
describe(getName(__filename), () => {
|
||||||
const options = {
|
const options = {
|
||||||
hostType: PLATFORM_TYPE_GITHUB,
|
hostType: PLATFORM_TYPE_GITHUB,
|
||||||
|
@ -17,6 +20,8 @@ describe(getName(__filename), () => {
|
||||||
// reset module
|
// reset module
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
|
|
||||||
|
delete process.env.HTTP_PROXY;
|
||||||
|
|
||||||
// clean up hostRules
|
// clean up hostRules
|
||||||
hostRules.clear();
|
hostRules.clear();
|
||||||
hostRules.add({
|
hostRules.add({
|
||||||
|
@ -32,6 +37,10 @@ describe(getName(__filename), () => {
|
||||||
httpMock.setup();
|
httpMock.setup();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
delete process.env.HTTP_PROXY;
|
||||||
|
});
|
||||||
|
|
||||||
it('adds token', () => {
|
it('adds token', () => {
|
||||||
expect(applyHostRules(url, { ...options })).toMatchInlineSnapshot(`
|
expect(applyHostRules(url, { ...options })).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
|
@ -61,4 +70,29 @@ describe(getName(__filename), () => {
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('uses http2', () => {
|
||||||
|
hostRules.add({ enableHttp2: true });
|
||||||
|
expect(applyHostRules(url, { ...options, token: 'xxx' }))
|
||||||
|
.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"hostType": "github",
|
||||||
|
"http2": true,
|
||||||
|
"token": "xxx",
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('disables http2', () => {
|
||||||
|
process.env.HTTP_PROXY = 'http://proxy';
|
||||||
|
bootstrap();
|
||||||
|
hostRules.add({ enableHttp2: true });
|
||||||
|
expect(applyHostRules(url, { ...options, token: 'xxx' }))
|
||||||
|
.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"hostType": "github",
|
||||||
|
"token": "xxx",
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
import { hasProxy } from '../../proxy';
|
||||||
import * as hostRules from '../host-rules';
|
import * as hostRules from '../host-rules';
|
||||||
import { GotOptions } from './types';
|
import { GotOptions } from './types';
|
||||||
|
|
||||||
|
@ -30,5 +31,9 @@ export function applyHostRules(url: string, inOptions: GotOptions): GotOptions {
|
||||||
options[param] = foundRules[param];
|
options[param] = foundRules[param];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!hasProxy() && foundRules.enableHttp2 === true) {
|
||||||
|
options.http2 = true;
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue