-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(launchpad): adding a launchpad to control flagd (#194)
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> Co-authored-by: warber <72415058+warber@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
364 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Flagd Testbed Launchpad Application | ||
|
||
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. | ||
|
||
## Features | ||
|
||
- **Start and Stop `flagd`:** | ||
Use `/start` and `/stop` endpoints to manage the `flagd` process. | ||
|
||
- **Dynamic Configuration Toggling:** | ||
The `/change` endpoint toggles the `defaultVariant` for a specific flag and saves the change to the configuration file. | ||
|
||
## Endpoints | ||
|
||
### 1. `/start` | ||
- **Method:** `POST` | ||
- **Description:** Starts the `flagd` binary with the specified configuration. | ||
- **Query Parameters:** | ||
- `config` (optional): Name of the configuration to load. Defaults to `"default"`. | ||
- **Example:** | ||
```bash | ||
curl -X POST http://localhost:8080/start?config=my-config | ||
``` | ||
|
||
### 2. `/stop` | ||
- **Method:** `POST` | ||
- **Description:** Stops the running `flagd` binary. | ||
- **Example:** | ||
```bash | ||
curl -X POST http://localhost:8080/stop | ||
``` | ||
|
||
### 3. `/change` | ||
- **Method:** `POST` | ||
- **Description:** Toggles the `defaultVariant` for the flag `changing-flag` between `"foo"` and `"bar"` and saves the updated configuration to the file `changing-flag.json`. | ||
- **Example:** | ||
```bash | ||
curl -X POST http://localhost:8080/change | ||
``` | ||
|
||
## Configuration Files | ||
|
||
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`. | ||
|
||
### Example Configuration (`changing-flag.json`) | ||
|
||
```json | ||
{ | ||
"flags": { | ||
"changing-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"foo": "foo", | ||
"bar": "bar" | ||
}, | ||
"defaultVariant": "foo" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Running the Application | ||
|
||
1. **Build and Run the Application:** | ||
```bash | ||
go run main.go | ||
``` | ||
|
||
2. **Start the `flagd` Binary:** | ||
```bash | ||
curl -X POST http://localhost:8080/start?config=default | ||
``` | ||
|
||
3. **Stop the `flagd` Binary:** | ||
```bash | ||
curl -X POST http://localhost:8080/stop | ||
``` | ||
|
||
4. **Toggle the Default Variant:** | ||
```bash | ||
curl -X POST http://localhost:8080/change | ||
``` | ||
|
||
|
||
## Development Notes | ||
|
||
- Ensure that `flagd` is available in the application directory or adjust the path accordingly. | ||
- Modify the `changing-flag.json` file if additional flags or configurations are required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"sources": [ | ||
{ | ||
"uri": "testing-flags.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "changing-flag.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "custom-ops.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "evaluator-refs.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "edge-case-flags.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "zero-flags.json", | ||
"provider": "file" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"server-cert-path": "/ssl/server-cert.pem", | ||
"server-key-path": "/ssl/server-key.pem", | ||
"sources": [ | ||
{ | ||
"uri": "testing-flags.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "changing-flag.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "custom-ops.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "evaluator-refs.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "edge-case-flags.json", | ||
"provider": "file" | ||
}, | ||
{ | ||
"uri": "zero-flags.json", | ||
"provider": "file" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module openfeature.com/flagd-testbed/launchpad | ||
|
||
go 1.22.4 |
Oops, something went wrong.