Skip to main content
Version: v1.51.2

GitHub

Overview​

Fetch the configuration from files stored in a GitHub repository. This retriever will perform an HTTP Request with your GitHub configuration on the GitHub API to get your flags.
info

GitHub has rate limits, be sure to correctly set your PollingInterval to avoid reaching the limit.

If the rate limit is reached, the retriever will log an error and will stop polling until GitHub allows it again.

Configure the relay proxy​

To configure your relay proxy to use the GitHub retriever, you need to add the following configuration to your relay proxy configuration file:

goff-proxy.yaml
# ...
retrievers:
- kind: github
repositorySlug: thomaspoignant/go-feature-flag
path: config/flag/my-flags.yaml
# ...
Field nameMandatoryTypeDefaultDescription
kindstringnoneValue should be github.
This field is mandatory and describes which retriever you are using.
repositorySlugstringnoneThe repository slug of the GitHub repository where your file is located (ex: thomaspoignant/go-feature-flag).
pathstringnonePath to the file inside the repository (ex: config/flag/my-flags.yaml).
branchstringmainThe branch we should check in the repository.
tokenstringnoneGithub token used to access a private repository, you need the repo permission (how to create a GitHub token).
baseUrlstringnoneThe base URL for the GitHub API. Use this for GitHub Enterprise or self-hosted instances (ex: https://github.acme.com/api/v3). If not specified, defaults to https://api.github.com.
timeoutstring10000Timeout in millisecond used when calling GitHub.

Configure the GO Module​

To configure your GO module to use the GitHub retriever, you need to add the following configuration to your ffclient.Config{} object:

example.go
err := ffclient.Init(ffclient.Config{
PollingInterval: 3 * time.Second,
Retriever: &githubretriever.Retriever{
RepositorySlug: "thomaspoignant/go-feature-flag",
Branch: "main",
FilePath: "testdata/flag-config.goff.yaml",
GithubToken: "XXXX",
Timeout: 2 * time.Second,
},
})
defer ffclient.Close()
FieldMandatoryDescription
RepositorySlugYour GitHub slug org/repo-name.
FilePathThe path of your file.
BranchThe branch where your file is.
Default: main
GithubTokenGithub token is used to access a private repository, you need the repo permission (how to create a GitHub token).
BaseURLThe base URL for the GitHub API. Use this for GitHub Enterprise or self-hosted instances (ex: https://github.acme.com/api/v3). If not specified, defaults to https://api.github.com.
TimeoutTimeout for the HTTP call
Default: 10 seconds

GitHub Enterprise / Self-hosted instances​

If you are using a GitHub Enterprise or self-hosted instance, you can configure the baseUrl field to point to your instance's API endpoint.

Relay Proxy Configuration​

goff-proxy.yaml
# ...
retrievers:
- kind: github
repositorySlug: myorg/myrepo
path: config/flag/my-flags.yaml
baseUrl: "https://github.acme.com/api/v3"
# ...

GO Module Configuration​

example.go
err := ffclient.Init(ffclient.Config{
PollingInterval: 3 * time.Second,
Retriever: &githubretriever.Retriever{
RepositorySlug: "myorg/myrepo",
Branch: "main",
FilePath: "config/flag/my-flags.yaml",
BaseURL: "https://github.acme.com/api/v3",
GithubToken: "XXXX",
},
})
defer ffclient.Close()