Introduce parameter object for API params that travel together

This commit is contained in:
Sam Partington 2020-11-23 14:18:05 +00:00
parent b15854c9af
commit 20567b5888
36 changed files with 247 additions and 253 deletions

11
lib/api-client.js generated
View file

@ -28,7 +28,7 @@ var DisallowedAPIVersionReason;
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
let hasBeenWarnedAboutVersion = false;
exports.getApiClient = function (githubAuth, githubUrl, mode, logger, allowLocalRun = false, possibleFailureExpected = false) {
exports.getApiClient = function (apiDetails, mode, logger, allowLocalRun = false, possibleFailureExpected = false) {
if (util_1.isLocalRun() && !allowLocalRun) {
throw new Error("Invalid API call in local run");
}
@ -58,8 +58,8 @@ exports.getApiClient = function (githubAuth, githubUrl, mode, logger, allowLocal
}
});
});
return new customOctokit(githubUtils.getOctokitOptions(githubAuth, {
baseUrl: getApiUrl(githubUrl),
return new customOctokit(githubUtils.getOctokitOptions(apiDetails.auth, {
baseUrl: getApiUrl(apiDetails.url),
userAgent: "CodeQL Action",
log: console_log_level_1.default({ level: "debug" }),
}));
@ -79,7 +79,10 @@ function getApiUrl(githubUrl) {
// Once all code has been converted this function should be removed or made canonical
// and called only from the action entrypoints.
function getActionsApiClient(allowLocalRun = false) {
return exports.getApiClient(actions_util_1.getRequiredInput("token"), actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"), "actions", logging_1.getActionsLogger(), allowLocalRun);
return exports.getApiClient({
auth: actions_util_1.getRequiredInput("token"),
url: actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
}, "actions", logging_1.getActionsLogger(), allowLocalRun);
}
exports.getActionsApiClient = getActionsApiClient;
function apiVersionInRange(version, minimumVersion, maximumVersion) {