|
11 | 11 |
|
12 | 12 |
|
13 | 13 |
|
14 |
| -A feature flag solution, with YAML file in the backend (S3, HTTP, local file ...). |
15 |
| -No server to install, just add a file in a central system *(HTTP, S3, ...)* and all your services will react to the changes of this file. |
| 14 | +A feature flag solution, with YAML file in the backend (S3, GitHub, HTTP, local file ...). |
| 15 | +No server to install, just add a file in a central system *(HTTP, S3, GitHub, ...)* and all your services will react to the changes of this file. |
16 | 16 |
|
17 | 17 |
|
18 | 18 | If you are not familiar with feature flags also called feature Toggles you can read this [article of Martin Fowler](https://www.martinfowler.com/articles/feature-toggles.html)
|
19 |
| -that explain why this is a great pattern. |
20 |
| -I've also write an [article](https://medium.com/better-programming/feature-flags-and-how-to-iterate-quickly-7e3371b9986) that explain why feature flags can help you to iterate quickly. |
| 19 | +that explains why this is a great pattern. |
| 20 | +I've also wrote an [article](https://medium.com/better-programming/feature-flags-and-how-to-iterate-quickly-7e3371b9986) that explains why feature flags can help you to iterate quickly. |
21 | 21 |
|
22 | 22 | ## Installation
|
23 | 23 | ```bash
|
@@ -52,16 +52,26 @@ if hasFlag {
|
52 | 52 | `go-feature-flags` support different ways of retrieving the flag file.
|
53 | 53 | We can have only one source for the file, if you set multiple sources in your configuration, only one will be take in consideration.
|
54 | 54 |
|
55 |
| -### From a file |
| 55 | +### From GitHub |
56 | 56 | ```go
|
57 | 57 | err := ffclient.Init(ffclient.Config{
|
58 | 58 | PollInterval: 3,
|
59 |
| - LocalFile: "file-example.yaml", |
| 59 | + GithubRetriever: &ffClient.GithubRetriever{ |
| 60 | + RepositorySlug: "thomaspoignant/go-feature-flag", |
| 61 | + Branch: "main", |
| 62 | + FilePath: "testdata/test.yaml", |
| 63 | + GithubToken: "XXXX", |
| 64 | + }, |
60 | 65 | })
|
61 | 66 | defer ffclient.Close()
|
62 | 67 | ```
|
| 68 | +To configure the access to your GitHub file: |
| 69 | +- **RepositorySlug**: your GitHub slug `org/repo-name`. **MANDATORY** |
| 70 | +- **FilePath**: the path of your file. **MANDATORY** |
| 71 | +- **Branch**: the branch where your file is *(default is `main`)*. |
| 72 | +- **GithubToken**: Github token is used to access a private repository, you need the `repo` permission *([how to create a GitHub token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token))*. |
63 | 73 |
|
64 |
| -I will not recommend using a file to store your flags except if it is in a shared folder for all your services. |
| 74 | +**Warning**: GitHub has rate limits, so be sure to not reach them when setting your `PollInterval`. |
65 | 75 |
|
66 | 76 | ### From an HTTP endpoint
|
67 | 77 | ```go
|
@@ -100,6 +110,18 @@ To configure your S3 file location:
|
100 | 110 | - **Item**: The location of your file in the bucket. **MANDATORY**
|
101 | 111 | - **AwsConfig**: An instance of `aws.Config` that configure your access to AWS *(see [this documentation for more info](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html))*. **MANDATORY**
|
102 | 112 |
|
| 113 | +### From a file |
| 114 | +```go |
| 115 | +err := ffclient.Init(ffclient.Config{ |
| 116 | + PollInterval: 3, |
| 117 | + LocalFile: "file-example.yaml", |
| 118 | +}) |
| 119 | +defer ffclient.Close() |
| 120 | +``` |
| 121 | + |
| 122 | +*I will not recommend using a file to store your flags except if it is in a shared folder for all your services.* |
| 123 | + |
| 124 | + |
103 | 125 | ## Flags file format
|
104 | 126 | `go-feature-flag` is to avoid to have to host a backend to manage your feature flags and to keep them centralized by using a file a source.
|
105 | 127 | Your file should be a YAML file with a list of flags *([see example](testdata/test.yaml))*.
|
|
0 commit comments