Rename FeatureFlag -> Feature
This commit is contained in:
parent
b16314e16c
commit
6de05e4b24
24 changed files with 116 additions and 124 deletions
38
lib/feature-flags.js
generated
38
lib/feature-flags.js
generated
|
|
@ -19,35 +19,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createFeatureFlags = exports.GitHubFeatureFlags = exports.featureFlagConfig = exports.FeatureFlag = void 0;
|
||||
exports.createFeatureFlags = exports.GitHubFeatureFlags = exports.featureConfig = exports.Feature = void 0;
|
||||
const api_client_1 = require("./api-client");
|
||||
const util = __importStar(require("./util"));
|
||||
var FeatureFlag;
|
||||
(function (FeatureFlag) {
|
||||
FeatureFlag["BypassToolcacheEnabled"] = "bypass_toolcache_enabled";
|
||||
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||
FeatureFlag["TrapCachingEnabled"] = "trap_caching_enabled";
|
||||
FeatureFlag["GolangExtractionReconciliationEnabled"] = "golang_extraction_reconciliation_enabled";
|
||||
FeatureFlag["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
||||
exports.featureFlagConfig = {
|
||||
[FeatureFlag.BypassToolcacheEnabled]: {
|
||||
var Feature;
|
||||
(function (Feature) {
|
||||
Feature["BypassToolcacheEnabled"] = "bypass_toolcache_enabled";
|
||||
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||
Feature["TrapCachingEnabled"] = "trap_caching_enabled";
|
||||
Feature["GolangExtractionReconciliationEnabled"] = "golang_extraction_reconciliation_enabled";
|
||||
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||
})(Feature = exports.Feature || (exports.Feature = {}));
|
||||
exports.featureConfig = {
|
||||
[Feature.BypassToolcacheEnabled]: {
|
||||
envVar: "CODEQL_BYPASS_TOOLCACHE",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[FeatureFlag.MlPoweredQueriesEnabled]: {
|
||||
[Feature.MlPoweredQueriesEnabled]: {
|
||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||
minimumVersion: "2.7.5",
|
||||
},
|
||||
[FeatureFlag.TrapCachingEnabled]: {
|
||||
[Feature.TrapCachingEnabled]: {
|
||||
envVar: "CODEQL_TRAP_CACHING",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[FeatureFlag.GolangExtractionReconciliationEnabled]: {
|
||||
[Feature.GolangExtractionReconciliationEnabled]: {
|
||||
envVar: "CODEQL_GOLANG_EXTRACTION_RECONCILIATION",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[FeatureFlag.CliConfigFileEnabled]: {
|
||||
[Feature.CliConfigFileEnabled]: {
|
||||
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
||||
minimumVersion: "2.10.1",
|
||||
},
|
||||
|
|
@ -72,20 +72,20 @@ class GitHubFeatureFlags {
|
|||
* @throws if a `minimumVersion` is specified for the feature flag, and `codeql` is not provided.
|
||||
*/
|
||||
async getValue(flag, codeql) {
|
||||
if (!codeql && exports.featureFlagConfig[flag].minimumVersion) {
|
||||
if (!codeql && exports.featureConfig[flag].minimumVersion) {
|
||||
throw new Error(`A minimum version is specified for feature flag ${flag}, but no instance of CodeQL was provided.`);
|
||||
}
|
||||
// Bypassing the toolcache is disabled in test mode.
|
||||
if (flag === FeatureFlag.BypassToolcacheEnabled && util.isInTestMode()) {
|
||||
if (flag === Feature.BypassToolcacheEnabled && util.isInTestMode()) {
|
||||
return false;
|
||||
}
|
||||
const envVar = (process.env[exports.featureFlagConfig[flag].envVar] || "").toLocaleLowerCase();
|
||||
const envVar = (process.env[exports.featureConfig[flag].envVar] || "").toLocaleLowerCase();
|
||||
// Do not use this feature if user explicitly disables it via an environment variable.
|
||||
if (envVar === "false") {
|
||||
return false;
|
||||
}
|
||||
// Never use this feature if the CLI version explicitly can't support it.
|
||||
const minimumVersion = exports.featureFlagConfig[flag].minimumVersion;
|
||||
const minimumVersion = exports.featureConfig[flag].minimumVersion;
|
||||
if (codeql && minimumVersion) {
|
||||
if (!(await util.codeQlVersionAbove(codeql, minimumVersion))) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue