Launchpad is a lightweight HTTP server built in Go that controls a flagd binary and provides endpoints to manage its lifecycle and configuration. The application also allows toggling a flag's defaultVariant dynamically and saves the updated configuration to a file.
Additionally, launchpad will write the whole configuration as one combined JSON file into the "flags" directory with the name "allFlags.json". This file can be utilized for File provider tests, instead of implementing a json manipulation in all languages. Mount the folder of the docker image to a local directory, and it will generate the file into this folder.
-
Start and Stop
flagd: Use/startand/stopendpoints to manage theflagdprocess. -
Dynamic Configuration Toggling: The
/changeendpoint toggles thedefaultVariantfor a specific flag and saves the change to the configuration file.
- Method:
POST - Description: Starts the
flagdbinary with the specified configuration. - Query Parameters:
config(optional): Name of the configuration to load. Defaults to"default".
- Example:
curl -X POST http://localhost:8080/start?config=my-config
- Method:
POST - Description: Stops the running
flagdbinary. - Example:
curl -X POST http://localhost:8080/stop
- Method:
POST - Description: Toggles the
defaultVariantfor the flagchanging-flagbetween"foo"and"bar"and saves the updated configuration to the filechanging-flag.json. - Example:
curl -X POST http://localhost:8080/change
-
Method:
POST -
Description: restarts the running
flagdbinary. -
Query Parameters:
seconds(optional): Time between stop and start. Defaults to"5".
-
Example:
curl -X POST http://localhost:8080/restart?seconds=5 ```
The application relies on JSON configuration files to manage flags for flagd. The configuration files are stored locally, and the /change endpoint modifies the file changing-flag.json.
{
"flags": {
"changing-flag": {
"state": "ENABLED",
"variants": {
"foo": "foo",
"bar": "bar"
},
"defaultVariant": "foo"
}
}
}-
Build and Run the Application:
go run main.go
-
Start the
flagdBinary:curl -X POST http://localhost:8080/start?config=default -
Stop the
flagdBinary:curl -X POST http://localhost:8080/stop
-
Toggle the Default Variant:
curl -X POST http://localhost:8080/change
- Ensure that
flagdis available in the application directory or adjust the path accordingly. - Modify the
changing-flag.jsonfile if additional flags or configurations are required.