Leveraging Flipt evaluation references for preview environments.
https://github.com/organization/repository.git
.
The application is made up of three directories:
cmd/api
- contains our Go backend API and loads the UIui
- contains our React frontendpkg/performance
- contains our Flipt feature flag definition/api/performance
endpoint:
showPerformanceHistory
feature flag. If the flag is enabled, we return the sales performance data.
Also of note, we’re using the FLIPT_CLIENT_REFERENCE
environment variable to pass in the reference to Flipt in the evaluation call. This is used to serve a different Git branch for each preview environment. We’ll talk more about this later.
pkg/performance
directory. This directory contains a single file called features.yml
. This file contains the definition of our showPerformanceHistory
feature flag.
features.yml
and you can spread your flag
definitions across multiple files. Check out our docs on locating flag
state to learn more.FLIPT_CLIENT_REFERENCE
environment variable to the Git branch name. This will allow us to serve a different Git branch for each preview environment.
To do this, we’ll need to add a step to our GitHub Actions workflow that sets the FLIPT_CLIENT_REFERENCE
environment variable to the Git branch name.
FLIPT_ADDRESS
environment variable to the address of our Flipt instance. This could also be configured in your application via a config file.
features.yml
file to set the enabled
field to true
.
main
branch of our Git repository by default, which is what it continues to show in the UI.
FLIPT_CLIENT_REFERENCE
environment variable is set to the Git branch name.
main
Git branch. This means that when we merge our pull request, our application will automatically start using the new flag state.
GET /api/v1/flags
) as well as all of our evaluation endpoints (e.g. POST /evaluate/v1/boolean
).
We’ve also added support for references in all of our server side REST SDKs and our client side SDKs.
References currently only work with Git, and our git
backend, like all of the declarative storage backends, mandates that the UI is read-only.
We have thoughts on how this could change in the future, but for now, this is a limitation.
You always have your editor, Git and the SCMs (GitHub, GitLab etc) for state management in the meantime.
Flipt will automatically sync your feature flag definitions to Flipt in the background. Each of these backends work by polling their sources (git, oci, local directory or object store) and the interval can be configured.
Check out the Configuration: Storage: Declarative for details on adjusting these intervals.