Introduce parameter object for API params that travel together
This commit is contained in:
parent
b15854c9af
commit
20567b5888
36 changed files with 247 additions and 253 deletions
|
|
@ -17,14 +17,18 @@ export enum DisallowedAPIVersionReason {
|
|||
ACTION_TOO_NEW,
|
||||
}
|
||||
|
||||
export interface GitHubApiDetails {
|
||||
auth: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
export const getApiClient = function (
|
||||
githubAuth: string,
|
||||
githubUrl: string,
|
||||
apiDetails: GitHubApiDetails,
|
||||
mode: Mode,
|
||||
logger: Logger,
|
||||
allowLocalRun = false,
|
||||
|
|
@ -78,8 +82,8 @@ export const getApiClient = function (
|
|||
});
|
||||
});
|
||||
return new customOctokit(
|
||||
githubUtils.getOctokitOptions(githubAuth, {
|
||||
baseUrl: getApiUrl(githubUrl),
|
||||
githubUtils.getOctokitOptions(apiDetails.auth, {
|
||||
baseUrl: getApiUrl(apiDetails.url),
|
||||
userAgent: "CodeQL Action",
|
||||
log: consoleLogLevel({ level: "debug" }),
|
||||
})
|
||||
|
|
@ -105,8 +109,10 @@ function getApiUrl(githubUrl: string): string {
|
|||
// and called only from the action entrypoints.
|
||||
export function getActionsApiClient(allowLocalRun = false) {
|
||||
return getApiClient(
|
||||
getRequiredInput("token"),
|
||||
getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
{
|
||||
auth: getRequiredInput("token"),
|
||||
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
},
|
||||
"actions",
|
||||
getActionsLogger(),
|
||||
allowLocalRun
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue