mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Make auth property on GitHubApiDetails optional
This commit is contained in:
40
lib/entry-points.js
generated
40
lib/entry-points.js
generated
@@ -26401,7 +26401,7 @@ var require_utils4 = __commonJS({
|
||||
})();
|
||||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||||
exports2.GitHub = exports2.defaults = exports2.context = void 0;
|
||||
exports2.getOctokitOptions = getOctokitOptions2;
|
||||
exports2.getOctokitOptions = getOctokitOptions;
|
||||
var Context = __importStar2(require_context());
|
||||
var Utils = __importStar2(require_utils3());
|
||||
var core_1 = (init_dist_src2(), __toCommonJS(dist_src_exports));
|
||||
@@ -26417,7 +26417,7 @@ var require_utils4 = __commonJS({
|
||||
}
|
||||
};
|
||||
exports2.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports2.defaults);
|
||||
function getOctokitOptions2(token, options) {
|
||||
function getOctokitOptions(token, options) {
|
||||
const opts = Object.assign({}, options || {});
|
||||
const auth2 = Utils.getAuthString(token, opts);
|
||||
if (auth2) {
|
||||
@@ -140010,7 +140010,7 @@ var require_utils10 = __commonJS({
|
||||
}
|
||||
};
|
||||
exports2.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports2.defaults);
|
||||
function getOctokitOptions2(token, options) {
|
||||
function getOctokitOptions(token, options) {
|
||||
const opts = Object.assign({}, options || {});
|
||||
const auth2 = Utils.getAuthString(token, opts);
|
||||
if (auth2) {
|
||||
@@ -140018,7 +140018,7 @@ var require_utils10 = __commonJS({
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
exports2.getOctokitOptions = getOctokitOptions2;
|
||||
exports2.getOctokitOptions = getOctokitOptions;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -170729,22 +170729,22 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false, proxy =
|
||||
const auth2 = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
|
||||
const retryingOctokit = githubUtils.GitHub.plugin(retry);
|
||||
const requestOptions = makeProxyRequestOptions(proxy);
|
||||
return new retryingOctokit(
|
||||
githubUtils.getOctokitOptions(auth2, {
|
||||
baseUrl: apiDetails.apiURL,
|
||||
userAgent: `CodeQL-Action/${getActionVersion()}`,
|
||||
log: {
|
||||
debug: core6.debug,
|
||||
info: core6.info,
|
||||
warn: core6.warning,
|
||||
error: core6.error
|
||||
},
|
||||
request: requestOptions,
|
||||
retry: {
|
||||
doNotRetry: DO_NOT_RETRY_STATUSES
|
||||
}
|
||||
})
|
||||
);
|
||||
const opts = {
|
||||
auth: auth2 !== void 0 ? `token ${auth2}` : void 0,
|
||||
baseUrl: apiDetails.apiURL,
|
||||
userAgent: `CodeQL-Action/${getActionVersion()}`,
|
||||
log: {
|
||||
debug: core6.debug,
|
||||
info: core6.info,
|
||||
warn: core6.warning,
|
||||
error: core6.error
|
||||
},
|
||||
request: requestOptions,
|
||||
retry: {
|
||||
doNotRetry: DO_NOT_RETRY_STATUSES
|
||||
}
|
||||
};
|
||||
return new retryingOctokit(opts);
|
||||
}
|
||||
function getApiDetails(env = getEnv()) {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as githubUtils from "@actions/github/lib/utils";
|
||||
import type { OctokitOptions } from "@octokit/core";
|
||||
import * as retry from "@octokit/plugin-retry";
|
||||
import { RequestRequestOptions } from "@octokit/types";
|
||||
import {
|
||||
@@ -133,22 +134,24 @@ function createApiClientWithDetails(
|
||||
(allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
||||
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
||||
const requestOptions = makeProxyRequestOptions(proxy);
|
||||
return new retryingOctokit(
|
||||
githubUtils.getOctokitOptions(auth, {
|
||||
baseUrl: apiDetails.apiURL,
|
||||
userAgent: `CodeQL-Action/${getActionVersion()}`,
|
||||
log: {
|
||||
debug: core.debug,
|
||||
info: core.info,
|
||||
warn: core.warning,
|
||||
error: core.error,
|
||||
},
|
||||
request: requestOptions,
|
||||
retry: {
|
||||
doNotRetry: DO_NOT_RETRY_STATUSES,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const opts: OctokitOptions = {
|
||||
auth: auth !== undefined ? `token ${auth}` : undefined,
|
||||
baseUrl: apiDetails.apiURL,
|
||||
userAgent: `CodeQL-Action/${getActionVersion()}`,
|
||||
log: {
|
||||
debug: core.debug,
|
||||
info: core.info,
|
||||
warn: core.warning,
|
||||
error: core.error,
|
||||
},
|
||||
request: requestOptions,
|
||||
retry: {
|
||||
doNotRetry: DO_NOT_RETRY_STATUSES,
|
||||
},
|
||||
};
|
||||
|
||||
return new retryingOctokit(opts);
|
||||
}
|
||||
|
||||
export function getApiDetails(env: ReadOnlyEnv = getEnv()): GitHubApiDetails {
|
||||
|
||||
@@ -126,7 +126,7 @@ function mockReleaseApi({
|
||||
});
|
||||
}
|
||||
|
||||
function mockApiDetails(apiDetails: GitHubApiDetails) {
|
||||
function mockApiDetails(apiDetails: Required<GitHubApiDetails>) {
|
||||
// This is a workaround to mock `api.getApiDetails()` since it doesn't seem to be possible to
|
||||
// mock this directly. The difficulty is that `getApiDetails()` is called locally in
|
||||
// `api-client.ts`, but `sinon.stub(api, "getApiDetails")` only affects calls to
|
||||
|
||||
@@ -38,7 +38,7 @@ export type GitHubInstance = {
|
||||
/** Represents a {@link GitHubInstance} with a token for accessing the API. */
|
||||
export type GitHubApiDetails = GitHubInstance & {
|
||||
/** The token to use for accessing the API of the GitHub instance. */
|
||||
auth: string;
|
||||
auth?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user