Refactor handling of feature flags

This commit centralizes how feature flags are handled. All feature flags
must now add an entry in the `featureFlagConfig` dictionary. This
dictionary associates the flag with an environment variable name and
optionally a minimum version for CodeQL.

The new logic is:

- if the environment variable is set to false: disabled
- if the minimum version requirement specified and met: disabled
- if the environment variable is set to true: enable
- Otherwise check feature flag enablement from the server
This commit is contained in:
Andrew Eisenberg 2022-10-05 15:54:07 -07:00
parent 24c8de16fa
commit e5c3375225
27 changed files with 400 additions and 368 deletions

3
lib/init-action.js generated
View file

@ -160,8 +160,9 @@ async function run() {
}
async function getTrapCachingEnabled(featureFlags) {
const trapCaching = (0, actions_util_1.getOptionalInput)("trap-caching");
if (trapCaching !== undefined)
if (trapCaching !== undefined) {
return trapCaching === "true";
}
return await featureFlags.getValue(feature_flags_1.FeatureFlag.TrapCachingEnabled);
}
async function runWrapper() {