Address comments from review
- Change env var name for `MlPoweredQueriesEnabled` - Throw error if minimumVersion is specified, but CodeQL argument is not supplied. - Fix failing tests. Note that I removed a config-utils test because it is no longer relevant since we handle codeql minimum versions in the `getValue` function.
This commit is contained in:
parent
e5c3375225
commit
b16314e16c
9 changed files with 202 additions and 129 deletions
17
lib/feature-flags.js
generated
17
lib/feature-flags.js
generated
|
|
@ -36,7 +36,7 @@ exports.featureFlagConfig = {
|
|||
minimumVersion: undefined,
|
||||
},
|
||||
[FeatureFlag.MlPoweredQueriesEnabled]: {
|
||||
envVar: "CODEQL_VERSION_ML_POWERED_QUERIES",
|
||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||
minimumVersion: "2.7.5",
|
||||
},
|
||||
[FeatureFlag.TrapCachingEnabled]: {
|
||||
|
|
@ -59,7 +59,22 @@ class GitHubFeatureFlags {
|
|||
this.repositoryNwo = repositoryNwo;
|
||||
this.logger = logger;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param flag The feature flag to check.
|
||||
* @param codeql An optional CodeQL object. If provided, and a `minimumVersion` is specified for the
|
||||
* feature flag, the version of the CodeQL CLI will be checked against the minimum version.
|
||||
* If the version is less than the minimum version, the feature flag will be considered
|
||||
* disabled. If not provided, and a `minimumVersion` is specified for the feature flag, the
|
||||
* this function will throw.
|
||||
* @returns true if the feature flag is enabled, false otherwise.
|
||||
*
|
||||
* @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) {
|
||||
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()) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue