Skip to content

Commit ab99a8e

Browse files
feat: add Flipt to playground (#293)
1 parent d4a4468 commit ab99a8e

File tree

9 files changed

+183
-4
lines changed

9 files changed

+183
-4
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ Thumbs.db
4545
# yalc stuff
4646
.yalc
4747
yalc.lock
48+
49+
config/flipt/flipt.db

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ If you're brand new to feature flagging, consider reviewing the [What are featur
2828
- [Harness](#harness)
2929
- [LaunchDarkly](#launchdarkly)
3030
- [Flagsmith](#flagsmith)
31+
- [Flipt](#flipt)
3132
- [Experimenting beyond the demo](#experimenting-beyond-the-demo)
3233
- [Evaluation context](#evaluation-context)
3334
- [Troubleshooting](#troubleshooting)
@@ -420,6 +421,13 @@ Now that everything is configured, you should be able to [start the demo](#how-t
420421
Now that everything is configured, you should be able to [start the demo](#how-to-run-the-demo). Once it's started, select `flagsmith` from the provider list located at the bottom right of your screen. You should now be able to control the demo app via Flagsmith!
421422
</details>
422423

424+
### Flipt
425+
426+
[Flipt](https://www.flipt.io/) is an open-source feature management platform that's fully self-hosted.
427+
It's easy to set up, has no seat limits, and is built for developers from scale-ups to enterprises.
428+
429+
After [starting the demo](#how-to-run-the-demo), the Flipt UI is available at [http://localhost:8080](http://localhost:8080).
430+
423431
## Experimenting beyond the demo
424432

425433
### Evaluation context

config/flipt/flipt.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: "1.2"
2+
namespace: default
3+
flags:
4+
- key: new-welcome-message
5+
name: new-welcome-message
6+
type: BOOLEAN_FLAG_TYPE
7+
description: Controls the welcome banner message
8+
enabled: true
9+
rollouts:
10+
- threshold:
11+
percentage: 100
12+
value: true
13+
- key: hex-color
14+
name: hex-color
15+
type: VARIANT_FLAG_TYPE
16+
description: Controls the UI color
17+
enabled: true
18+
variants:
19+
- key: c05543
20+
name: red
21+
- key: 2f5230
22+
name: green
23+
- key: 0d507b
24+
name: blue
25+
- key: d4ac0d
26+
name: yellow
27+
rules:
28+
- segment: Signed-In-Users
29+
distributions:
30+
- variant: d4ac0d
31+
rollout: 100
32+
- segment: All-Users
33+
distributions:
34+
- variant: 2f5230
35+
rollout: 100
36+
- key: use-remote-fib-service
37+
name: use-remote-fib-service
38+
type: BOOLEAN_FLAG_TYPE
39+
description: Controls whether the remote fib service is used
40+
enabled: true
41+
rollouts:
42+
- segment:
43+
key: Signed-In-Users
44+
value: true
45+
- segment:
46+
key: All-Users
47+
- key: fib-algo
48+
name: fib-algo
49+
type: VARIANT_FLAG_TYPE
50+
description: The algorithm to calculate the fibbonaci sequence
51+
enabled: true
52+
variants:
53+
- key: binet
54+
name: binet
55+
- key: memo
56+
name: memo
57+
- key: loop
58+
name: loop
59+
- key: recursive
60+
name: recursive
61+
rules:
62+
- segment: All-Users
63+
distributions:
64+
- variant: memo
65+
rollout: 100
66+
segments:
67+
- key: All-Users
68+
name: All Users
69+
description: All users are matched
70+
match_type: ALL_MATCH_TYPE
71+
- key: Signed-In-Users
72+
name: Signed In Users
73+
description: Users that are signed in
74+
constraints:
75+
- type: STRING_COMPARISON_TYPE
76+
property: email
77+
operator: suffix
78+
value: '@faas.com'
79+
match_type: ALL_MATCH_TYPE

docker-compose.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ services:
2323
- GO_FEATURE_FLAG_URL=http://go-feature-flag:1031
2424
- GO_FEATURE_FLAG_WEB_URL=http://localhost:1031
2525
- FIB_SERVICE_URL=http://fib-service:30001
26+
- FLIPT_URL=http://flipt:8080
27+
- FLIPT_WEB_URL=http://localhost:8080
2628
- FIB_SERVICE_USER
2729
- FIB_SERVICE_PASS
2830
# Provider values come from the .env
@@ -59,6 +61,7 @@ services:
5961
- OTEL_EXPORTER_JAEGER_AGENT_PORT=6832
6062
- OTEL_SERVICE_NAME=fibonacci-service
6163
- GO_FEATURE_FLAG_URL=http://go-feature-flag:1031
64+
- FLIPT_URL=http://flipt:8080
6265
- FIB_SERVICE_USER
6366
- FIB_SERVICE_PASS
6467
# Provider values come from the .env
@@ -129,5 +132,34 @@ services:
129132
ports:
130133
- "1031:1031"
131134

135+
init_flipt:
136+
image: docker.flipt.io/flipt/flipt:v1.42.0
137+
command: ["./flipt", "import", "/var/opt/flipt/flipt.yml"]
138+
environment:
139+
FLIPT_LOG_LEVEL: debug
140+
FLIPT_META_TELEMETRY_ENABLED: false
141+
FLIPT_DB_URL: "/var/opt/flipt/flipt.db"
142+
volumes:
143+
- "./config/flipt/flipt.yml:/var/opt/flipt/flipt.yml"
144+
- "flipt:/var/opt/flipt"
145+
146+
flipt:
147+
image: docker.flipt.io/flipt/flipt:v1.42.0
148+
command: ["./flipt", "--force-migrate"]
149+
environment:
150+
FLIPT_CORS_ENABLED: true
151+
FLIPT_TRACING_ENABLED: true
152+
FLIPT_TRACING_EXPORTER: otlp
153+
FLIPT_TRACING_OTLP_ENDPOINT: "otel-collector:4317"
154+
FLIPT_DB_URL: "/var/opt/flipt/flipt.db"
155+
volumes:
156+
- "./config/flipt/flipt.yml:/var/opt/flipt/flipt.yml"
157+
- "flipt:/var/opt/flipt"
158+
depends_on:
159+
- init_flipt
160+
ports:
161+
- '8080:8080'
162+
132163
volumes:
133164
flagd-flags:
165+
flipt:

package-lock.json

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"@openfeature/env-var-provider": "^0.3.0",
2727
"@openfeature/flagd-provider": "^0.13.0",
2828
"@openfeature/flagd-web-provider": "^0.7.0",
29+
"@openfeature/flipt-provider": "^0.1.0",
30+
"@openfeature/flipt-web-provider": "^0.1.0",
2931
"@openfeature/go-feature-flag-provider": "^0.7.0",
3032
"@openfeature/go-feature-flag-web-provider": "^0.2.0",
3133
"@openfeature/nestjs-sdk": "^0.1.3-experimental",

packages/provider/src/lib/provider.service.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ import {
1919
FLAGD_OFREP_PROVIDER_ID,
2020
FLAGD_PROVIDER_ID,
2121
FLAGSMITH_PROVIDER_ID,
22+
FLIPT_PROVIDER_ID,
2223
GO_OFREP_PROVIDER_ID,
2324
GO_PROVIDER_ID,
2425
HARNESS_PROVIDER_ID,
2526
ProviderId,
2627
SPLIT_PROVIDER_ID,
2728
} from '@openfeature/utils';
2829
import { OFREPProvider } from '@openfeature/ofrep-provider';
30+
import { FliptProvider } from '@openfeature/flipt-provider';
2931

3032
type ProviderMap = Record<
3133
ProviderId,
@@ -114,14 +116,14 @@ export class ProviderService {
114116
endpoint: process.env.GO_FEATURE_FLAG_URL as string,
115117
}),
116118
available: () => !!process.env.GO_FEATURE_FLAG_URL,
117-
url: process.env.GO_FEATURE_FLAG_WEB_URL as string
119+
url: process.env.GO_FEATURE_FLAG_WEB_URL as string,
118120
},
119121
[GO_OFREP_PROVIDER_ID]: {
120122
factory: () => {
121123
return new OFREPProvider({ baseUrl: process.env.GO_FEATURE_FLAG_URL as string });
122124
},
123125
available: () => !!process.env.GO_FEATURE_FLAG_URL,
124-
url: process.env.GO_FEATURE_FLAG_WEB_URL as string
126+
url: process.env.GO_FEATURE_FLAG_WEB_URL as string,
125127
},
126128
[FLAGSMITH_PROVIDER_ID]: {
127129
factory: () => {
@@ -162,6 +164,13 @@ export class ProviderService {
162164
available: () => !!process.env.HARNESS_KEY && !!process.env.HARNESS_KEY_WEB,
163165
webCredential: process.env.HARNESS_KEY_WEB,
164166
},
167+
[FLIPT_PROVIDER_ID]: {
168+
factory: () => {
169+
return new FliptProvider('default', { url: process.env.FLIPT_URL as string });
170+
},
171+
available: () => !!process.env.FLIPT_URL,
172+
url: process.env.FLIPT_WEB_URL,
173+
},
165174
};
166175

167176
constructor() {
@@ -206,7 +215,7 @@ export class ProviderService {
206215
host: p[1].host,
207216
port: p[1].port,
208217
tls: p[1].tls,
209-
url: p[1].url
218+
url: p[1].url,
210219
};
211220
});
212221
}

packages/ui/src/app/demos.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
FLAGD_OFREP_PROVIDER_ID,
77
FLAGD_PROVIDER_ID,
88
FLAGSMITH_PROVIDER_ID,
9+
FLIPT_PROVIDER_ID,
910
GO_OFREP_PROVIDER_ID,
1011
GO_PROVIDER_ID,
1112
HARNESS_PROVIDER_ID,
@@ -33,6 +34,7 @@ import { styledFib3rSteps } from './demos/fib3r/tour';
3334
import { JSON_UPDATED } from './types';
3435
import { getData } from './utils';
3536
import { GoFeatureFlagWebProvider } from '@openfeature/go-feature-flag-web-provider';
37+
import { FliptWebProvider } from '@openfeature/flipt-web-provider';
3638

3739
type ProviderMap = Record<
3840
string,
@@ -130,6 +132,12 @@ export class Demos extends Component<
130132
return new SplitWebProvider(this.getProviderCredential(SPLIT_PROVIDER_ID));
131133
},
132134
},
135+
[FLIPT_PROVIDER_ID]: {
136+
factory: () => {
137+
const fliptConfig = this.state.availableProviders.find((p) => p.id === FLIPT_PROVIDER_ID);
138+
return new FliptWebProvider('default', { url: fliptConfig?.url });
139+
},
140+
},
133141
};
134142

135143
constructor(props: Record<string, never>) {

packages/utils/src/lib/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const SPLIT_PROVIDER_ID = 'split';
88
export const CB_PROVIDER_ID = 'cloudbees';
99
export const FLAGSMITH_PROVIDER_ID = 'flagsmith';
1010
export const HARNESS_PROVIDER_ID = 'harness';
11+
export const FLIPT_PROVIDER_ID = 'flipt';
1112

1213
export type ProviderId =
1314
| typeof ENV_PROVIDER_ID
@@ -19,7 +20,8 @@ export type ProviderId =
1920
| typeof SPLIT_PROVIDER_ID
2021
| typeof CB_PROVIDER_ID
2122
| typeof FLAGSMITH_PROVIDER_ID
22-
| typeof HARNESS_PROVIDER_ID;
23+
| typeof HARNESS_PROVIDER_ID
24+
| typeof FLIPT_PROVIDER_ID;
2325

2426
export interface AvailableProvider {
2527
id: ProviderId;

0 commit comments

Comments
 (0)