summaryrefslogtreecommitdiff
path: root/jstests/libs/feature_flag_util.js
blob: 1fe8f4b75c0ac003218438e50934eddf29c7c2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Utilities for feature flags.
 */
var FeatureFlagUtil = class {
    /**
     * Returns true if feature flag is enabled, false otherwise.
     */
    static isEnabled(db, featureFlag) {
        return eval(
            `const admin = db.getSiblingDB("admin");
            const flagDoc = admin.runCommand({getParameter: 1, featureFlag${featureFlag}: 1});
            const fcvDoc = admin.runCommand({getParameter: 1, featureCompatibilityVersion: 1});
            flagDoc.hasOwnProperty("featureFlag${featureFlag}") &&
                flagDoc.featureFlag${featureFlag}.value &&
                (!fcvDoc.hasOwnProperty("featureCompatibilityVersion") ||
                MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version,
                                            flagDoc.featureFlag${featureFlag}.fcv) >= 0);`
        );
    }
};