Skip to content

Commit 138a458

Browse files
toddbaertbeeme1mr
andauthored
docs: command and query cheat sheet, context injection (open-feature#1839)
Adds a "cheat sheet" with a a bunch of simple, easily searchable examples for: - starting flagd - docker and binary - with file source - with http source - with multiple sources - with header and static context injection - calling OFREP with curl - evaluating multiple flags - evaluating one flag - using the `flagd-selector` header - calling proto API - streaming and evaluation - flagd-selector ... and more [DIRECT PREVIEW](https://deploy-preview-1839--polite-licorice-3db33c.netlify.app/reference/cheat-sheet/) :play_or_pause_button: The idea is this is a searchable reference. Concepts are not explained we have lots of that elsewhere. This is just for quick reference for useful commands. --------- Signed-off-by: Todd Baert <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent 5e4218c commit 138a458

File tree

13 files changed

+729
-7
lines changed

13 files changed

+729
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM squidfunk/mkdocs-material:9.5
1+
FROM squidfunk/mkdocs-material:9.7.1
22
RUN pip install mkdocs-include-markdown-plugin
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"$schema": "https://flagd.dev/schema/v0/flags.json",
3+
"flags": {
4+
"payment-provider": {
5+
"state": "ENABLED",
6+
"variants": {
7+
"slash": "slash",
8+
"billbuddy": "billbuddy",
9+
"cube": "cube"
10+
},
11+
"defaultVariant": "slash"
12+
},
13+
"max-transaction-amount": {
14+
"state": "ENABLED",
15+
"variants": {
16+
"standard": 1000,
17+
"elevated": 5000,
18+
"unlimited": 999999
19+
},
20+
"defaultVariant": "standard",
21+
"targeting": {
22+
"if": [
23+
{ "===": [{ "var": "account-verified" }, true] },
24+
"elevated",
25+
"standard"
26+
]
27+
}
28+
},
29+
"enable-crypto-payments": {
30+
"state": "ENABLED",
31+
"variants": {
32+
"on": true,
33+
"off": false
34+
},
35+
"defaultVariant": "off",
36+
"targeting": {
37+
"if": [
38+
{ "in": [{ "var": "country" }, ["us", "ca", "uk", "de"]] },
39+
"on",
40+
"off"
41+
]
42+
}
43+
}
44+
},
45+
"metadata": {
46+
"flagSetId": "payment-flags"
47+
}
48+
}

docs/assets/cheat-sheet-flags.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"$schema": "https://flagd.dev/schema/v0/flags.json",
3+
"flags": {
4+
"simple-boolean": {
5+
"state": "ENABLED",
6+
"variants": {
7+
"on": true,
8+
"off": false
9+
},
10+
"defaultVariant": "on"
11+
},
12+
"simple-string": {
13+
"state": "ENABLED",
14+
"variants": {
15+
"greeting": "Hello, World!",
16+
"farewell": "Goodbye, World!"
17+
},
18+
"defaultVariant": "greeting"
19+
},
20+
"simple-number": {
21+
"state": "ENABLED",
22+
"variants": {
23+
"low": 10,
24+
"medium": 50,
25+
"high": 100
26+
},
27+
"defaultVariant": "medium"
28+
},
29+
"simple-object": {
30+
"state": "ENABLED",
31+
"variants": {
32+
"config-a": {
33+
"theme": "light",
34+
"maxItems": 10
35+
},
36+
"config-b": {
37+
"theme": "dark",
38+
"maxItems": 25
39+
}
40+
},
41+
"defaultVariant": "config-a"
42+
},
43+
"user-tier-flag": {
44+
"state": "ENABLED",
45+
"variants": {
46+
"basic": "basic-features",
47+
"premium": "premium-features",
48+
"enterprise": "enterprise-features"
49+
},
50+
"defaultVariant": "basic",
51+
"targeting": {
52+
"if": [
53+
{ "===": [{ "var": "tier" }, "enterprise"] },
54+
"enterprise",
55+
{ "if": [
56+
{ "===": [{ "var": "tier" }, "premium"] },
57+
"premium",
58+
null
59+
]}
60+
]
61+
}
62+
},
63+
"email-based-feature": {
64+
"state": "ENABLED",
65+
"variants": {
66+
"on": true,
67+
"off": false
68+
},
69+
"defaultVariant": "off",
70+
"targeting": {
71+
"if": [
72+
{ "ends_with": [{ "var": "email" }, "@example.com"] },
73+
"on",
74+
null
75+
]
76+
}
77+
},
78+
"region-config": {
79+
"state": "ENABLED",
80+
"variants": {
81+
"us": { "currency": "USD", "dateFormat": "MM/DD/YYYY" },
82+
"eu": { "currency": "EUR", "dateFormat": "DD/MM/YYYY" },
83+
"default": { "currency": "USD", "dateFormat": "YYYY-MM-DD" }
84+
},
85+
"defaultVariant": "default",
86+
"targeting": {
87+
"if": [
88+
{ "in": [{ "var": "region" }, ["us", "usa", "united-states"]] },
89+
"us",
90+
{ "if": [
91+
{ "in": [{ "var": "region" }, ["eu", "europe", "uk", "de", "fr"]] },
92+
"eu",
93+
null
94+
]}
95+
]
96+
}
97+
}
98+
},
99+
"metadata": {
100+
"flagSetId": "app-flags"
101+
}
102+
}

docs/concepts/selectors.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ In flagd, **selectors** provide a way to query flags based on different criteria
1313
- **Selector**: A query expression that filters flags by source, flag set, or other criteria
1414
- **Flag Set Metadata**: The selector information is "reflected" back in response metadata for transparency
1515

16+
See the [cheat sheet](../reference/cheat-sheet.md#using-the-selector-header) for practical examples of using selectors.
17+
1618
!!! tip
1719

1820
The `flagSetId` + `key` combination represents the unique identifier for a flag.

docs/concepts/syncs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Syncs are a core part of flagd; they are the abstraction that enables different sources for feature flag definitions.
44
flagd can connect to one or more sync sources.
5+
See the [cheat sheet](../reference/cheat-sheet.md#running-flagd) for quick startup examples with different sync sources.
56

67
## Available syncs
78

docs/faq.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ flagd is sub-project of OpenFeature and aims to be fully [OpenFeature-compliant]
3030
3131
You can run flagd as a standalone application, accessible over HTTP or gRPC, or you can embed it into your application.
3232
Please see [architecture](./architecture.md) and [installation](./installation.md) for more information.
33+
For quick command examples, see the [cheat sheet](./reference/cheat-sheet.md).
3334

3435
---
3536

0 commit comments

Comments
 (0)