Added proxy support for azure agent and github runner

This commit is contained in:
Thomas VAILLIER
2020-03-11 22:43:44 +01:00
committed by Artur
parent e1e31a379b
commit a2f365cab2
34 changed files with 256 additions and 180 deletions

View File

@@ -2,6 +2,7 @@ import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import * as http from 'typed-rest-client/HttpClient'
import * as ifm from 'typed-rest-client/Interfaces'
import { inject, injectable } from 'inversify'
import { TYPES, IExecResult, IBuildAgent } from './models'
@@ -23,13 +24,20 @@ export class DotnetTool implements IDotnetTool {
protected versionManager: IVersionManager
private httpClient: http.HttpClient
private static readonly nugetRoot: string =
'https://api-v2v3search-0.nuget.org/'
constructor(
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
@inject(TYPES.IVersionManager) versionManager: IVersionManager
) {
this.buildAgent = buildAgent
this.versionManager = versionManager
this.httpClient = new http.HttpClient('dotnet')
this.httpClient = new http.HttpClient(
'dotnet',
undefined,
this.buildAgent.proxyConfiguration(DotnetTool.nugetRoot)
)
}
public disableTelemetry(): void {
@@ -133,9 +141,12 @@ export class DotnetTool implements IDotnetTool {
} ${includePrerelease ? 'including pre-releases' : ''}`
)
const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(
toolName.toLowerCase()
)}&prerelease=${includePrerelease ? 'true' : 'false'}&semVerLevel=2.0.0`
const downloadPath = `${
DotnetTool.nugetRoot
}query?q=${encodeURIComponent(toolName.toLowerCase())}&prerelease=${
includePrerelease ? 'true' : 'false'
}&semVerLevel=2.0.0`
const res = await this.httpClient.get(downloadPath)
if (!res || res.message.statusCode !== 200) {

View File

@@ -1,3 +1,5 @@
import { IRequestOptions } from 'typed-rest-client/Interfaces'
export const TYPES = {
IBuildAgent: Symbol.for('BuildAgent'),
IDotnetTool: Symbol.for('DotnetTool'),
@@ -25,6 +27,7 @@ export interface IExecResult {
export interface IBuildAgent {
agentName: string
proxyConfiguration(url: string): IRequestOptions
find(toolName: string, versionSpec: string, arch?: string): string
cacheDir(
sourceDir: string,