Skip to main content
Version: v0.17.3

Configure a flag

The goal of this module is to avoid having to host a backend to manage your feature flags and, to keep them centralized by using a single file as a source.

Your file must be a valid YAML, JSON or TOML file with a list of flags (examples: YAML, JSON, TOML).

Example

A flag configuration looks like:

YAML

test-flag:
percentage: 100
rule: key eq "random-key"
true: true
false: false
default: false
disable: false
trackEvents: true
rollout:
experimentation:
start: 2021-03-20T00:00:00.10-05:00
end: 2021-03-21T00:00:00.10-05:00

test-flag2:
rule: key eq "not-a-key"
percentage: 100
true: true
false: false
default: false

JSON

{
"test-flag": {
"percentage": 100,
"rule": "key eq \"random-key\"",
"true": true,
"false": false,
"default": false,
"disable": false,
"trackEvents": true,
"rollout": {
"experimentation": {
"start": "2021-03-20T05:00:00.100Z",
"end": "2021-03-21T05:00:00.100Z"
}
}
},
"test-flag2": {
"rule": "key eq \"not-a-key\"",
"percentage": 100,
"true": true,
"false": false,
"default": false
}
}

TOML

[test-flag]
percentage = 100.0
rule = "key eq \"random-key\""
true = true
false = false
default = false
disable = false
trackEvents = true

[test-flag.rollout]

[test-flag.rollout.experimentation]
start = 2021-03-20T05:00:00.100Z
end = 2021-03-21T05:00:00.100Z

[test-flag2]
rule = "key eq \"not-a-key\""
percentage = 100.0
true = true
false = false
default = false

Format details

FieldDescription
flag-keyThe flag-key is the name of your flag.
It must be unique.
On the example the flag keys are test-flag and test-flag2.
trueThe value return by the flag if apply to the user (rule is evaluated to true) and user is in the active percentage.
falseThe value return by the flag if apply to the user (rule is evaluated to true) and user is not in the active percentage.
defaultThe value return by the flag if not apply to the user (rule is evaluated to false).
percentage(optional)
Percentage of the users affect by the flag.
Default: 0

The percentage is compute by doing a hash of the user key (100000 variations), it means that you can have 3 numbers after the comma.
rule(optional)
This is the query use to select on which user the flag should apply.
Rule format is describe in the rule format section.
If no rule set, the flag apply to all users (percentage still apply).
disable(optional)
True if the flag is disabled.
Default: false
trackEvents(optional)
False if you don't want to export the data in your data exporter.
Default: true
rollout(optional)
rollout contains a specific rollout strategy you want to use.
See rollout section for more details.

Rule format

The rule format is based on the nikunjy/rules library.

All the operations can be written capitalized or lowercase (ex: eq or EQ can be used).
Logical Operations supported are AND OR.

Compare Expression and their definitions (a|b means you can use either one of the two a or b):

OperatorDescription
eq | ==equals to
ne | !=not equals to
lt | <less than
gt | >greater than
le | <=less than equal to
ge | >=greater than equal to
cocontains
swstarts with
ewends with
inin a list
prpresent
notnot of a logical expression

Examples

  • Select a specific user: key eq "example@example.com"
  • Select all identified users: anonymous ne true
  • Select a user with a custom property: userId eq "12345"

Advanced configurations

You can have advanced configurations for your flag to have specific behavior for them, such as:

Get the latest GO Feature Flag updates