From 4810d499c1c8128dd611056ca52e270127c76d8c Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:05:30 -0500 Subject: [PATCH 01/11] chore: bump flagd version to 0.11.5 Signed-off-by: Michael Beemer --- flagd-demo/assets/scripts/intro_foreground.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flagd-demo/assets/scripts/intro_foreground.sh b/flagd-demo/assets/scripts/intro_foreground.sh index ff8a87e..58f6f8a 100644 --- a/flagd-demo/assets/scripts/intro_foreground.sh +++ b/flagd-demo/assets/scripts/intro_foreground.sh @@ -1,9 +1,9 @@ #!/bin/bash -DEBUG_VERSION=12 +DEBUG_VERSION=13 GITEA_VERSION=1.19 TEA_CLI_VERSION=0.9.2 -FLAGD_VERSION=0.4.5 +FLAGD_VERSION=0.11.5 # Download and install flagd wget -O flagd.tar.gz https://github.com/open-feature/flagd/releases/download/flagd%2Fv${FLAGD_VERSION}/flagd_${FLAGD_VERSION}_Linux_x86_64.tar.gz @@ -153,7 +153,7 @@ tea login add \ # Clone the template repo tea repo create --name=flags --branch=main --init=true > /dev/null 2>&1 git clone http://openfeature:openfeature@0.0.0.0:3000/openfeature/flags -wget -O ~/flags/example_flags.flagd.json https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.flagd.json +wget -O ~/flags/example_flags.flagd.json https://raw.githubusercontent.com/open-feature/flagd/refs/tags/flagd/v${FLAGD_VERSION}/samples/example_flags.flagd.json cd ~/flags git config credential.helper cache git add -A @@ -163,4 +163,4 @@ git push # ---------------------------------------------# # 🎉 Installation Complete 🎉 # # Please proceed now... # -# ---------------------------------------------# \ No newline at end of file +# ---------------------------------------------# From bbe7e60ce62349565db6ae5d72f4a26ac6149b2c Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:25:02 -0500 Subject: [PATCH 02/11] chore: fix line numbers Signed-off-by: Michael Beemer --- flagd-demo/step3.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flagd-demo/step3.md b/flagd-demo/step3.md index 2c84cf2..0261990 100644 --- a/flagd-demo/step3.md +++ b/flagd-demo/step3.md @@ -8,7 +8,7 @@ curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -d '{"flagKey": "headerColor", "context": {} }' ```{{exec}} -This should return `red` because the `defaultVariant` is set to `red` in Git ([see here]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L95)). +This should return `red` because the `defaultVariant` is set to `red` in Git ([see here]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L96)). ## Change Flag Color @@ -16,7 +16,7 @@ Using GitOps, change the `defaultVariant` from `red` to `yellow`: Open the Editor and find this file: `~/flags/example_flags.flagd.json`{{}} -Change the `defaultVariant`{{}} (line `95`{{}}) from `red`{{}} to `yellow`{{}}. +Change the `defaultVariant`{{}} (line `96`{{}}) from `red`{{}} to `yellow`{{}}. Change back to Tab 2 and commit these changes to your Git repository by clicking this text: @@ -27,7 +27,7 @@ git commit -m "update header color" git push ```{{exec}} -[Line 95]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L95) should now be `"defaultVariant": "yellow",` +[Line 95]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L96) should now be `"defaultVariant": "yellow",` ## Retrieve the Flag Value Again @@ -37,4 +37,4 @@ This time you should receive `yellow`. curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -H "Content-Type: application/json" \ -d '{"flagKey": "headerColor", "context": {} }' -```{{exec}} \ No newline at end of file +```{{exec}} From f322421300551d9c0971cd64a5ad879368495dcb Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:30:16 -0500 Subject: [PATCH 03/11] chore: update targeting section based on the latest config Signed-off-by: Michael Beemer --- flagd-demo/step5.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/flagd-demo/step5.md b/flagd-demo/step5.md index 99f58f2..f5b571d 100644 --- a/flagd-demo/step5.md +++ b/flagd-demo/step5.md @@ -1,34 +1,26 @@ -So far you've seen a very basic feature flag. But often you need more flexibility *within* a given flag rule. +So far, you've seen a very basic feature flag. But often, you need more flexibility *within* a given flag rule. For this, OpenFeature provides a concept of targeting rules. Targeting rules allow you to be more specific in *who* receives a given flag value. -For example, look at [targetedFlag]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L126-L149). +For example, look at [fibAlgo]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L70-88). The rules can be read like this: -- By default, everyone receieves the flag `first` with the value of `AAA` **except**... -- When an `email` key is present containing `@openfeature.dev`, the returned flag is `second` with a value of `BBB`. -- When an `userAgent` key is present containing `Chrome`, the returned flag is `third` with a value of `CCC`. +- By default, everyone receives `recursive` **except**... +- When an `email` key ends with `@faas.com,` the returned variant is `binet` is returned. Try this out now: -This command should return the `first` variant with a value of `AAA`. +This command should return the `recursive` variant with a value of `recursive`. ``` curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -H "Content-Type: application/json" \ - -d '{"flagKey": "targetedFlag", "context": {} }' + -d '{"flagKey": "fibAlgo", "context": {} }' ```{{exec}} -This command should return the `second` variant with a value of `BBB`. +This command should return the `binet` variant with a value of `binet`. ``` curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -H "Content-Type: application/json" \ - -d '{"flagKey": "targetedFlag", "context": { "email": "me@openfeature.dev" } }' + -d '{"flagKey": "targetedFlag", "context": { "email": "me@faas.com" } }' ```{{exec}} - -This command should return the `third` variant with a value of `CCC`. -``` -curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ - -H "Content-Type: application/json" \ - -d '{"flagKey": "targetedFlag", "context": { "userAgent": "Chrome 1.2.3" } }' -```{{exec}} \ No newline at end of file From e46916e0f69bc9b880c555d81805b52cbe928df7 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:34:38 -0500 Subject: [PATCH 04/11] chore: fix outdated line highlights Signed-off-by: Michael Beemer --- flagd-demo/step6.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flagd-demo/step6.md b/flagd-demo/step6.md index b540b40..8a1875b 100644 --- a/flagd-demo/step6.md +++ b/flagd-demo/step6.md @@ -1,10 +1,10 @@ Need *even more* flexibility? Fractional evaluations allow for even more powerful flag targeting. -Look at the [headerColor]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L88-L125) flag. +Look at the [headerColor]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L89-120) flag. The available variants are `red`, `blue`, `green` and `yellow`. The `defaultVariant` should now be `yellow` (you changed it from `red` in the previous step). -So everyone receives `yellow`, right? No. There is a [targeting rule]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L97-L125) which can be read like this: +So everyone receives `yellow`, right? No. There is a [targeting rule]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L98-L119) which can be read like this: Everyone receives the `defaultVariant`{{}} of `yellow`{{}} **except**... @@ -58,4 +58,4 @@ Finally, prove that the `defaultVariant` is working (request the flag value with curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -H "Content-Type: application/json" \ -d '{"flagKey": "headerColor", "context": { } }' -```{{exec}} \ No newline at end of file +```{{exec}} From e4579fcf48017b1c1edf58a17a65ea0827984dab Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:35:27 -0500 Subject: [PATCH 05/11] chore: simplify tutorial Signed-off-by: Michael Beemer --- flagd-demo/finish.md | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/flagd-demo/finish.md b/flagd-demo/finish.md index 055463b..2987003 100644 --- a/flagd-demo/finish.md +++ b/flagd-demo/finish.md @@ -1,6 +1,7 @@ ## Congratulations! 🎉 -In this tutorial you have built an OpenFeature compliant feature flag backend using flagd. + +In this tutorial, you have built an OpenFeature compliant feature flag backend using flagd. You now have a pure GitOps feature flagging system. You can change only a JSON file and your application will automatically leverage the changes. @@ -8,35 +9,5 @@ This is just the beginning. flagd is capable of a lot more, such as providing mu ## What's Next? -In this tutorial, interaction with the flagd API was via `curl`{{}}. In reality, you wouldn't want your application becoming reliant on flagd - that's the entire premise of OpenFeature. Your application should be able to say "getAFlag" without caring about the backend system (flagd in this case). - -To achieve this, OpenFeature offers [language specific flagd providers](https://github.com/open-feature/flagd/blob/main/docs/usage/flagd_providers.md) which interact and "translate" to flagd code for you. If you are using Kubernetes - use the OpenFeature Operator which handles all of this complexity for you. Follow the [OpenFeature Operator hands-on tutorial](https://killercoda.com/open-feature/scenario/openfeature-operator-demo) or read the [OFO docs](https://github.com/open-feature/open-feature-operator/tree/main/docs). - -For example, in Golang, your application code would look like this: - -``` -package main - -import ( - "github.com/open-feature/go-sdk-contrib/providers/flagd/pkg" - "github.com/open-feature/go-sdk/pkg/openfeature" -) - -func main() { - openfeature.SetProvider(flagd.NewProvider( - flagd.WithHost("flagDHost"), - flagd.WithPort(8013), - )) - - // Get an openFeature client - client := openfeature.NewClient("myApp") - - // Get flag values - value, err := client.BooleanValue( - context.Background(), "myFlagValue", false, openfeature.EvaluationContext{}, - ) -} -``` - -- [Get started with flagd](https://github.com/open-feature/flagd) +- [Get started with flagd](https://flagd.dev/) - Questions? [Join the community](https://openfeature.dev/community/) From 58429b8bea2415f171d56d93254da7412053be55 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:41:45 -0500 Subject: [PATCH 06/11] chore: fix line number Signed-off-by: Michael Beemer --- flagd-demo/step3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flagd-demo/step3.md b/flagd-demo/step3.md index 0261990..6311eb2 100644 --- a/flagd-demo/step3.md +++ b/flagd-demo/step3.md @@ -27,7 +27,7 @@ git commit -m "update header color" git push ```{{exec}} -[Line 95]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L96) should now be `"defaultVariant": "yellow",` +[Line 96]({{TRAFFIC_HOST1_3000}}/openfeature/flags/src/branch/main/example_flags.flagd.json#L96) should now be `"defaultVariant": "yellow",` ## Retrieve the Flag Value Again From 54dfd3bd062397ff04ea11c457f21d0b96b1da89 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:42:27 -0500 Subject: [PATCH 07/11] chore: fix flag key name Signed-off-by: Michael Beemer --- flagd-demo/step5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flagd-demo/step5.md b/flagd-demo/step5.md index f5b571d..3789712 100644 --- a/flagd-demo/step5.md +++ b/flagd-demo/step5.md @@ -22,5 +22,5 @@ This command should return the `binet` variant with a value of `binet`. ``` curl -X POST {{TRAFFIC_HOST1_8013}}/schema.v1.Service/ResolveString \ -H "Content-Type: application/json" \ - -d '{"flagKey": "targetedFlag", "context": { "email": "me@faas.com" } }' + -d '{"flagKey": "fibAlgo", "context": { "email": "me@faas.com" } }' ```{{exec}} From 880603ca17211782e5cbf43962d60ce1a23f1e73 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:55:24 -0500 Subject: [PATCH 08/11] chore: update link Signed-off-by: Michael Beemer From 3ce59d6e08d8659bb2de50bd615fae7561d7818a Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 12:56:39 -0500 Subject: [PATCH 09/11] chore: update link ignore patterns Signed-off-by: Michael Beemer --- .markdown-link-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.markdown-link-check.json b/.markdown-link-check.json index 7f58346..065a694 100644 --- a/.markdown-link-check.json +++ b/.markdown-link-check.json @@ -7,7 +7,7 @@ "pattern": "localhost" }, { - "pattern": "^https://expressjs.com/" + "pattern": "^https://blog.thepete.net/" } ], "aliveStatusCodes": [200, 206] From 9663acec495118721b1b150df6697bfb885bea8d Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 13:18:50 -0500 Subject: [PATCH 10/11] Update .markdown-link-check.json Signed-off-by: Michael Beemer --- .markdown-link-check.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.markdown-link-check.json b/.markdown-link-check.json index 065a694..b20611a 100644 --- a/.markdown-link-check.json +++ b/.markdown-link-check.json @@ -5,9 +5,6 @@ }, { "pattern": "localhost" - }, - { - "pattern": "^https://blog.thepete.net/" } ], "aliveStatusCodes": [200, 206] From 9389ae345a9333d7ea9f51efb44bdad0f2555c3f Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 30 Dec 2024 13:19:09 -0500 Subject: [PATCH 11/11] Update makefile Signed-off-by: Michael Beemer --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index ce25bf7..7040abb 100644 --- a/makefile +++ b/makefile @@ -2,4 +2,4 @@ ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) .PHONY: linkcheck linkcheck: - find . -name \*.md -print0 | xargs -0 -n1 docker run --rm -i -v $(CURDIR):/tmp -w /tmp ghcr.io/tcort/markdown-link-check:stable -c .markdown-link-check.json + find . -name \*.md -print0 | xargs -0 -n1 docker run --rm -i -v $(CURDIR):/tmp -w /tmp ghcr.io/tcort/markdown-link-check:3.13.5 -c .markdown-link-check.json