mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
Use host rules
This commit is contained in:
parent
c3360f82d3
commit
620fa90803
2 changed files with 21 additions and 4 deletions
|
@ -2,6 +2,7 @@ import { getPkgReleases } from '..';
|
||||||
import { Fixtures } from '../../../../test/fixtures';
|
import { Fixtures } from '../../../../test/fixtures';
|
||||||
import * as httpMock from '../../../../test/http-mock';
|
import * as httpMock from '../../../../test/http-mock';
|
||||||
import { GlobalConfig } from '../../../config/global';
|
import { GlobalConfig } from '../../../config/global';
|
||||||
|
import * as hostRules from '../../../util/host-rules';
|
||||||
import type { AzurePipelinesTask } from './types';
|
import type { AzurePipelinesTask } from './types';
|
||||||
import { AzurePipelinesTasksDatasource } from '.';
|
import { AzurePipelinesTasksDatasource } from '.';
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ const marketplaceTasksPath =
|
||||||
describe('modules/datasource/azure-pipelines-tasks/index', () => {
|
describe('modules/datasource/azure-pipelines-tasks/index', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
GlobalConfig.reset();
|
GlobalConfig.reset();
|
||||||
|
hostRules.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null for unknown task', async () => {
|
it('returns null for unknown task', async () => {
|
||||||
|
@ -78,6 +80,12 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
|
||||||
endpoint: 'https://my.custom.domain',
|
endpoint: 'https://my.custom.domain',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hostRules.add({
|
||||||
|
hostType: AzurePipelinesTasksDatasource.id,
|
||||||
|
matchHost: 'my.custom.domain',
|
||||||
|
token: '123test',
|
||||||
|
});
|
||||||
|
|
||||||
httpMock
|
httpMock
|
||||||
.scope('https://my.custom.domain')
|
.scope('https://my.custom.domain')
|
||||||
.get('/_apis/distributedtask/tasks/')
|
.get('/_apis/distributedtask/tasks/')
|
||||||
|
@ -97,6 +105,12 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
|
||||||
endpoint: 'https://my.custom.domain',
|
endpoint: 'https://my.custom.domain',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hostRules.add({
|
||||||
|
hostType: AzurePipelinesTasksDatasource.id,
|
||||||
|
matchHost: 'my.custom.domain',
|
||||||
|
token: '123test',
|
||||||
|
});
|
||||||
|
|
||||||
httpMock
|
httpMock
|
||||||
.scope('https://my.custom.domain')
|
.scope('https://my.custom.domain')
|
||||||
.get('/_apis/distributedtask/tasks/')
|
.get('/_apis/distributedtask/tasks/')
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { GlobalConfig } from '../../../config/global';
|
import { GlobalConfig } from '../../../config/global';
|
||||||
import { cache } from '../../../util/cache/package/decorator';
|
import { cache } from '../../../util/cache/package/decorator';
|
||||||
|
import * as hostRules from '../../../util/host-rules';
|
||||||
import type { HttpOptions } from '../../../util/http/types';
|
import type { HttpOptions } from '../../../util/http/types';
|
||||||
import { id as versioning } from '../../versioning/loose';
|
import { id as versioning } from '../../versioning/loose';
|
||||||
import { Datasource } from '../datasource';
|
import { Datasource } from '../datasource';
|
||||||
|
@ -27,11 +28,13 @@ export class AzurePipelinesTasksDatasource extends Datasource {
|
||||||
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
||||||
const platform = GlobalConfig.get('platform');
|
const platform = GlobalConfig.get('platform');
|
||||||
const endpoint = GlobalConfig.get('endpoint');
|
const endpoint = GlobalConfig.get('endpoint');
|
||||||
|
const { token } = hostRules.find({
|
||||||
|
hostType: AzurePipelinesTasksDatasource.id,
|
||||||
|
url: endpoint,
|
||||||
|
});
|
||||||
|
|
||||||
if (platform === 'azure' && endpoint) {
|
if (platform === 'azure' && endpoint && token) {
|
||||||
const auth = Buffer.from(
|
const auth = Buffer.from(`renovate:${token}`).toString('base64');
|
||||||
`renovate:${process.env.RENOVATE_TOKEN}`,
|
|
||||||
).toString('base64');
|
|
||||||
const opts: HttpOptions = {
|
const opts: HttpOptions = {
|
||||||
headers: { authorization: `Basic ${auth}` },
|
headers: { authorization: `Basic ${auth}` },
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue