Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:
test:
go test -race -covermode=atomic -cover ./pkg/... -coverprofile=coverage.out
run:
go run main.go start -f file:config/samples/example_flags.json
go run main.go start -f file:config/samples/example_flags.flagd.json
install:
cp systemd/flagd.service /etc/systemd/system/flagd.service
mkdir -p /etc/flagd
Expand Down
134 changes: 134 additions & 0 deletions config/samples/example_flags.flagd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"flags": {
"myBoolFlag": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
},
"myStringFlag": {
"state": "ENABLED",
"variants": {
"key1": "val1",
"key2": "val2"
},
"defaultVariant": "key1"
},
"myFloatFlag": {
"state": "ENABLED",
"variants": {
"one": 1.23,
"two": 2.34
},
"defaultVariant": "one"
},
"myIntFlag": {
"state": "ENABLED",
"variants": {
"one": 1,
"two": 2
},
"defaultVariant": "one"
},
"myObjectFlag": {
"state": "ENABLED",
"variants": {
"object1": {
"key": "val"
},
"object2": {
"key": true
}
},
"defaultVariant": "object1"
},
"isColorYellow": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "off",
"targeting": {
"if": [
{
"==": [
{
"var": [
"color"
]
},
"yellow"
]
},
"on",
"off"
]
}
},
"fibAlgo": {
"variants": {
"recursive": "recursive",
"memo": "memo",
"loop": "loop",
"binet": "binet"
},
"defaultVariant": "recursive",
"state": "ENABLED",
"targeting": {
"if": [
{
"$ref": "emailWithFaas"
}, "binet", null
]
}
},
"headerColor": {
"variants": {
"red": "#FF0000",
"blue": "#0000FF",
"green": "#00FF00",
"yellow": "#FFFF00"
},
"defaultVariant": "red",
"state": "ENABLED",
"targeting": {
"if": [
{
"$ref": "emailWithFaas"
},
{
"fractionalEvaluation": [
"email",
[
"red",
25
],
[
"blue",
25
],
[
"green",
25
],
[
"yellow",
25
]
]
}, null
]
}
}
},
"$evaluators": {
"emailWithFaas": {
"in": ["@faas.com", {
"var": ["email"]
}]
}
}
}
88 changes: 88 additions & 0 deletions config/samples/example_flags.flagd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
flags:
myBoolFlag:
state: ENABLED
variants:
'on': true
'off': false
defaultVariant: 'on'
myStringFlag:
state: ENABLED
variants:
key1: val1
key2: val2
defaultVariant: key1
myFloatFlag:
state: ENABLED
variants:
one: 1.23
two: 2.34
defaultVariant: one
myIntFlag:
state: ENABLED
variants:
one: 1
two: 2
defaultVariant: one
myObjectFlag:
state: ENABLED
variants:
object1:
key: val
object2:
key: true
defaultVariant: object1
isColorYellow:
state: ENABLED
variants:
'on': true
'off': false
defaultVariant: 'off'
targeting:
if:
- "==":
- var:
- color
- yellow
- 'on'
- 'off'
fibAlgo:
variants:
recursive: recursive
memo: memo
loop: loop
binet: binet
defaultVariant: recursive
state: ENABLED
targeting:
if:
- "$ref": emailWithFaas
- binet
- null
headerColor:
variants:
red: "#FF0000"
blue: "#0000FF"
green: "#00FF00"
yellow: "#FFFF00"
defaultVariant: red
state: ENABLED
targeting:
if:
- "$ref": emailWithFaas
- fractionalEvaluation:
- email
- - red
- 25
- - blue
- 25
- - green
- 25
- - yellow
- 25
- null
"$evaluators":
emailWithFaas:
in:
- "@faas.com"
- var:
- email
36 changes: 36 additions & 0 deletions config/samples/example_flags_secondary.flagd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"flags": {
"myBoolFlag": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "off"
},
"isColorGreen": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "off",
"targeting": {
"if": [
{
"==": [
{
"var": [
"color"
]
},
"yellow"
]
},
"on",
"off"
]
}
}
}
}
8 changes: 4 additions & 4 deletions docs/usage/evaluation_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
1. Download sample flag configuration:

```shell
curl https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.json -o example_flags.json
curl https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.flagd.json -o example_flags.flagd.json
```

1. Run one of the following commands, depending on how [flagd was installed](../usage/getting_started.md):
- binary:

```shell
flagd start --uri file:example_flags.json
flagd start --uri file:example_flags.flagd.json
```

- Docker:

```shell
docker run -p 8013:8013 -v $(pwd)/:/etc/flagd/ -it --pull=always ghcr.io/open-feature/flagd:latest start --uri file:./etc/flagd/example_flags.json
docker run -p 8013:8013 -v $(pwd)/:/etc/flagd/ -it --pull=always ghcr.io/open-feature/flagd:latest start --uri file:./etc/flagd/example_flags.flagd.json
```

1. Changes made in `example_flags.json` will immediately take affect. Go ahead, give a shot!
1. Changes made in `example_flags.flagd.json` will immediately take affect. Go ahead, give a shot!

Flagd is now ready to perform flag evaluations over either HTTP or gRPC. In this example, we'll utilize HTTP via cURL.

Expand Down