From 2d0e9d956fbc99f2775821cfecdceb2b016d2b78 Mon Sep 17 00:00:00 2001 From: James Milligan <75740990+james-milligan@users.noreply.github.com> Date: Thu, 16 Feb 2023 09:40:57 +0000 Subject: [PATCH] docs: updated filepaths for schema store regex (#344) Signed-off-by: James Milligan ## This PR - updates file paths to conform to schema store regex ### Related Issues ### Notes ### Follow-up Tasks ### How to test --------- Signed-off-by: James Milligan Co-authored-by: Michael Beemer --- Makefile | 2 +- config/samples/example_flags.flagd.json | 134 ++++++++++++++++++ config/samples/example_flags.flagd.yaml | 88 ++++++++++++ .../example_flags_secondary.flagd.json | 36 +++++ docs/usage/evaluation_examples.md | 8 +- 5 files changed, 263 insertions(+), 5 deletions(-) create mode 100644 config/samples/example_flags.flagd.json create mode 100644 config/samples/example_flags.flagd.yaml create mode 100644 config/samples/example_flags_secondary.flagd.json diff --git a/Makefile b/Makefile index faeec24d4..b24870285 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/config/samples/example_flags.flagd.json b/config/samples/example_flags.flagd.json new file mode 100644 index 000000000..785f793a4 --- /dev/null +++ b/config/samples/example_flags.flagd.json @@ -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"] + }] + } + } +} diff --git a/config/samples/example_flags.flagd.yaml b/config/samples/example_flags.flagd.yaml new file mode 100644 index 000000000..dac0f4586 --- /dev/null +++ b/config/samples/example_flags.flagd.yaml @@ -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 \ No newline at end of file diff --git a/config/samples/example_flags_secondary.flagd.json b/config/samples/example_flags_secondary.flagd.json new file mode 100644 index 000000000..0307ddd30 --- /dev/null +++ b/config/samples/example_flags_secondary.flagd.json @@ -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" + ] + } + } + } +} \ No newline at end of file diff --git a/docs/usage/evaluation_examples.md b/docs/usage/evaluation_examples.md index 536b37b89..2333cdce6 100644 --- a/docs/usage/evaluation_examples.md +++ b/docs/usage/evaluation_examples.md @@ -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.