-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
292da48
commit a7e1e59
Showing
801 changed files
with
49,716 additions
and
2,994 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.KuduServiceClient = void 0; | ||
const util = require("util"); | ||
const WebClient_1 = require("azure-actions-webclient/WebClient"); | ||
const core = require("@actions/core"); | ||
class KuduServiceClient { | ||
constructor(scmUri, accessToken) { | ||
this._accesssToken = accessToken; | ||
this._scmUri = scmUri; | ||
this._webClient = new WebClient_1.WebClient(); | ||
} | ||
beginRequest(request, reqOptions, contentType) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
request.headers = request.headers || {}; | ||
request.headers["Authorization"] = "Basic " + this._accesssToken; | ||
request.headers['Content-Type'] = contentType || 'application/json; charset=utf-8'; | ||
if (!!this._cookie) { | ||
core.debug(`setting affinity cookie ${JSON.stringify(this._cookie)}`); | ||
request.headers['Cookie'] = this._cookie; | ||
} | ||
let retryCount = reqOptions && util.isNumber(reqOptions.retryCount) ? reqOptions.retryCount : 5; | ||
while (retryCount >= 0) { | ||
try { | ||
let httpResponse = yield this._webClient.sendRequest(request, reqOptions); | ||
if (httpResponse.headers['set-cookie'] && !this._cookie) { | ||
this._cookie = httpResponse.headers['set-cookie']; | ||
core.debug(`loaded affinity cookie ${JSON.stringify(this._cookie)}`); | ||
} | ||
return httpResponse; | ||
} | ||
catch (exception) { | ||
let exceptionString = exception.toString(); | ||
if (exceptionString.indexOf("Hostname/IP doesn't match certificates's altnames") != -1 | ||
|| exceptionString.indexOf("unable to verify the first certificate") != -1 | ||
|| exceptionString.indexOf("unable to get local issuer certificate") != -1) { | ||
core.warning('To use a certificate in App Service, the certificate must be signed by a trusted certificate authority. If your web app gives you certificate validation errors, you\'re probably using a self-signed certificate and to resolve them you need to export variable named ACTIONS_AZURE_REST_IGNORE_SSL_ERRORS to the value true.'); | ||
} | ||
if (retryCount > 0 && exceptionString.indexOf('Request timeout') != -1 && (!reqOptions || reqOptions.retryRequestTimedout)) { | ||
core.debug('encountered request timedout issue in Kudu. Retrying again'); | ||
retryCount -= 1; | ||
continue; | ||
} | ||
throw exception; | ||
} | ||
} | ||
}); | ||
} | ||
getRequestUri(uriFormat, queryParameters) { | ||
uriFormat = uriFormat[0] == "/" ? uriFormat : "/" + uriFormat; | ||
if (queryParameters && queryParameters.length > 0) { | ||
uriFormat = uriFormat + '?' + queryParameters.join('&'); | ||
} | ||
return this._scmUri + uriFormat; | ||
} | ||
getScmUri() { | ||
return this._scmUri; | ||
} | ||
} | ||
exports.KuduServiceClient = KuduServiceClient; |
Oops, something went wrong.