mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Use ActionState for getRemoteConfig
This commit is contained in:
28
lib/entry-points.js
generated
28
lib/entry-points.js
generated
@@ -151514,7 +151514,7 @@ function getConfigFileInput(logger, actions, repositoryProperties) {
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
async function getRemoteConfig(logger, configFile, apiDetails, validateConfig) {
|
||||
async function getRemoteConfig(actionState, configFile, apiDetails) {
|
||||
const address = parseRemoteFileAddress(getEnv(), configFile);
|
||||
const response = await getApiClientWithExternalAuth(apiDetails).rest.repos.getContent({
|
||||
owner: address.owner,
|
||||
@@ -151534,8 +151534,11 @@ async function getRemoteConfig(logger, configFile, apiDetails, validateConfig) {
|
||||
getConfigFileFormatInvalidMessage(configFile)
|
||||
);
|
||||
}
|
||||
const validateConfig = await actionState.features.getValue(
|
||||
"validate_db_config" /* ValidateDbConfig */
|
||||
);
|
||||
return parseUserConfig(
|
||||
logger,
|
||||
actionState.logger,
|
||||
configFile,
|
||||
Buffer.from(fileContents, "base64").toString("binary"),
|
||||
validateConfig
|
||||
@@ -152511,7 +152514,7 @@ async function downloadCacheWithTime(codeQL, languages, logger) {
|
||||
const trapCacheDownloadTime = import_perf_hooks.performance.now() - start;
|
||||
return { trapCaches, trapCacheDownloadTime };
|
||||
}
|
||||
async function loadUserConfig(logger, configFile, workspacePath, apiDetails, tempDir, validateConfig) {
|
||||
async function loadUserConfig(actionState, configFile, workspacePath, apiDetails, tempDir) {
|
||||
if (isLocal(configFile)) {
|
||||
if (configFile !== userConfigFromActionPath(tempDir)) {
|
||||
configFile = path10.resolve(workspacePath, configFile);
|
||||
@@ -152521,14 +152524,12 @@ async function loadUserConfig(logger, configFile, workspacePath, apiDetails, tem
|
||||
);
|
||||
}
|
||||
}
|
||||
return getLocalConfig(logger, configFile, validateConfig);
|
||||
} else {
|
||||
return await getRemoteConfig(
|
||||
logger,
|
||||
configFile,
|
||||
apiDetails,
|
||||
validateConfig
|
||||
const validateConfig = await actionState.features.getValue(
|
||||
"validate_db_config" /* ValidateDbConfig */
|
||||
);
|
||||
return getLocalConfig(actionState.logger, configFile, validateConfig);
|
||||
} else {
|
||||
return await getRemoteConfig(actionState, configFile, apiDetails);
|
||||
}
|
||||
}
|
||||
var OVERLAY_ANALYSIS_FEATURES = {
|
||||
@@ -152831,14 +152832,13 @@ async function initConfig(features, inputs) {
|
||||
logger.debug("No configuration file was provided");
|
||||
} else {
|
||||
logger.debug(`Using configuration file: ${inputs.configFile}`);
|
||||
const validateConfig = await features.getValue("validate_db_config" /* ValidateDbConfig */);
|
||||
const actionState = { logger, features, env: getEnv() };
|
||||
userConfig = await loadUserConfig(
|
||||
logger,
|
||||
actionState,
|
||||
inputs.configFile,
|
||||
inputs.workspacePath,
|
||||
inputs.apiDetails,
|
||||
tempDir,
|
||||
validateConfig
|
||||
tempDir
|
||||
);
|
||||
}
|
||||
const config = await initActionState(inputs, userConfig);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { performance } from "perf_hooks";
|
||||
import * as core from "@actions/core";
|
||||
import * as yaml from "js-yaml";
|
||||
|
||||
import { ActionState } from "./action-common";
|
||||
import {
|
||||
getActionVersion,
|
||||
getOptionalInput,
|
||||
@@ -78,6 +79,7 @@ import {
|
||||
Success,
|
||||
Failure,
|
||||
isHostedRunner,
|
||||
getEnv,
|
||||
} from "./util";
|
||||
|
||||
/**
|
||||
@@ -600,12 +602,11 @@ async function downloadCacheWithTime(
|
||||
}
|
||||
|
||||
async function loadUserConfig(
|
||||
logger: Logger,
|
||||
actionState: ActionState,
|
||||
configFile: string,
|
||||
workspacePath: string,
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
tempDir: string,
|
||||
validateConfig: boolean,
|
||||
): Promise<UserConfig> {
|
||||
if (isLocal(configFile)) {
|
||||
if (configFile !== userConfigFromActionPath(tempDir)) {
|
||||
@@ -618,14 +619,12 @@ async function loadUserConfig(
|
||||
);
|
||||
}
|
||||
}
|
||||
return getLocalConfig(logger, configFile, validateConfig);
|
||||
} else {
|
||||
return await getRemoteConfig(
|
||||
logger,
|
||||
configFile,
|
||||
apiDetails,
|
||||
validateConfig,
|
||||
const validateConfig = await actionState.features.getValue(
|
||||
Feature.ValidateDbConfig,
|
||||
);
|
||||
return getLocalConfig(actionState.logger, configFile, validateConfig);
|
||||
} else {
|
||||
return await getRemoteConfig(actionState, configFile, apiDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,14 +1160,13 @@ export async function initConfig(
|
||||
logger.debug("No configuration file was provided");
|
||||
} else {
|
||||
logger.debug(`Using configuration file: ${inputs.configFile}`);
|
||||
const validateConfig = await features.getValue(Feature.ValidateDbConfig);
|
||||
const actionState: ActionState = { logger, features, env: getEnv() };
|
||||
userConfig = await loadUserConfig(
|
||||
logger,
|
||||
actionState,
|
||||
inputs.configFile,
|
||||
inputs.workspacePath,
|
||||
inputs.apiDetails,
|
||||
tempDir,
|
||||
validateConfig,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ActionState } from "../action-common";
|
||||
import { ActionsEnv } from "../actions-util";
|
||||
import * as api from "../api-client";
|
||||
import * as errorMessages from "../error-messages";
|
||||
import { Feature } from "../feature-flags";
|
||||
import {
|
||||
RepositoryProperties,
|
||||
RepositoryPropertyName,
|
||||
@@ -42,18 +44,16 @@ export function getConfigFileInput(
|
||||
/**
|
||||
* Attempts to fetch a `UserConfig` from a remote `address`.
|
||||
*
|
||||
* @param logger The logger to use.
|
||||
* @param actionState The current Action state.
|
||||
* @param configFile The remote address of the configuration file.
|
||||
* @param apiDetails Information about how to connect to the API.
|
||||
* @param validateConfig Whether to validate the configuration.
|
||||
*
|
||||
* @returns The `UserConfig`, if it could be fetched and parsed successfully.
|
||||
*/
|
||||
export async function getRemoteConfig(
|
||||
logger: Logger,
|
||||
actionState: ActionState,
|
||||
configFile: string,
|
||||
apiDetails: api.GitHubApiCombinedDetails,
|
||||
validateConfig: boolean,
|
||||
): Promise<UserConfig> {
|
||||
const address = parseRemoteFileAddress(getEnv(), configFile);
|
||||
|
||||
@@ -79,8 +79,11 @@ export async function getRemoteConfig(
|
||||
);
|
||||
}
|
||||
|
||||
const validateConfig = await actionState.features.getValue(
|
||||
Feature.ValidateDbConfig,
|
||||
);
|
||||
return parseUserConfig(
|
||||
logger,
|
||||
actionState.logger,
|
||||
configFile,
|
||||
Buffer.from(fileContents, "base64").toString("binary"),
|
||||
validateConfig,
|
||||
|
||||
Reference in New Issue
Block a user