Skip to content

Commit 1da31ff

Browse files
docs
1 parent 3227b56 commit 1da31ff

17 files changed

+470
-318
lines changed

docs/docs/configuration/config-file.mdx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Config File
33
sidebarTitle: Config file
44
---
55

6+
import ConfigSchema from '/snippets/schemas/v3/index.schema.mdx'
7+
import EnvironmentOverridesSchema from '/snippets/schemas/v3/environmentOverrides.schema.mdx'
8+
69
When self-hosting Sourcebot, you **must** provide it a config file. This is done by defining a config file in a volume that's mounted to Sourcebot, and providing the path to this
710
file in the `CONFIG_PATH` environment variable. For example:
811

@@ -49,3 +52,103 @@ The following are settings that can be provided in your config file to modify So
4952
| `enablePublicAccess` **(deprecated)** | boolean | false || Use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead. |
5053
| `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the repo permission syncer should run. |
5154
| `experiment_userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the user permission syncer should run. |
55+
56+
# Tokens
57+
58+
Tokens are used to securely pass secrets to Sourcebot in a config file. They are used in various places, including connections, language model providers, auth providers, etc. Tokens can be passed as either environment variables or Google Cloud secrets:
59+
60+
<AccordionGroup>
61+
<Accordion title="Environment Variables">
62+
```json
63+
{
64+
"token": {
65+
"env": "TOKEN_NAME"
66+
}
67+
}
68+
```
69+
</Accordion>
70+
<Accordion title="Google Cloud Secrets">
71+
```json
72+
{
73+
"token": {
74+
"googleCloudSecret": "projects/<project-id>/secrets/<secret-name>/versions/<version-id>"
75+
}
76+
}
77+
```
78+
</Accordion>
79+
</AccordionGroup>
80+
81+
# Overriding environment variables from the config
82+
83+
You can override / set environment variables from the config file by using the `environmentOverrides` property. Overrides can be of type `string`, `number`, `boolean`, or a [token](/docs/configuration/config-file#tokens). Tokens are useful when you want to configure a environment variable using a Google Cloud Secret or other supported secret management service.
84+
85+
<AccordionGroup>
86+
<Accordion title="Token">
87+
```jsonc
88+
{
89+
"environmentOverrides": {
90+
"DATABASE_URL": {
91+
"type": "token",
92+
"value": {
93+
"googleCloudSecret": "projects/<id>/secrets/postgres-connection-string/versions/latest"
94+
}
95+
},
96+
"REDIS_URL": {
97+
"type": "token",
98+
"value": {
99+
"googleCloudSecret": "projects/<id>/secrets/redis-connection-string/versions/latest"
100+
}
101+
}
102+
},
103+
}
104+
```
105+
</Accordion>
106+
107+
<Accordion title="String">
108+
```jsonc
109+
{
110+
"environmentOverrides": {
111+
"EMAIL_FROM_ADDRESS": {
112+
"type": "string",
113+
"value": "hello@sourcebot.dev"
114+
}
115+
}
116+
}
117+
```
118+
</Accordion>
119+
120+
<Accordion title="Number">
121+
```jsonc
122+
{
123+
"environmentOverrides": {
124+
"SOURCEBOT_CHAT_MODEL_TEMPERATURE": {
125+
"type": "number",
126+
"value": 0.5
127+
}
128+
}
129+
}
130+
```
131+
</Accordion>
132+
133+
<Accordion title="Boolean">
134+
```jsonc
135+
{
136+
"environmentOverrides": {
137+
"SOURCEBOT_TELEMETRY_DISABLED": {
138+
"type": "boolean",
139+
"value": false
140+
}
141+
}
142+
}
143+
```
144+
</Accordion>
145+
</AccordionGroup>
146+
147+
148+
**Note:** Overrides are **not** set as system environment variables, and instead are resolved at runtime on startup and stored in memory.
149+
150+
<Accordion title="Schema reference">
151+
[schemas/v3/environmentOverrides.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/environmentOverrides.json)
152+
153+
<EnvironmentOverridesSchema />
154+
</Accordion>

docs/docs/configuration/environment-variables.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: Environment variables
33
sidebarTitle: Environment variables
4-
mode: "wide"
54
---
65

76
<Note>This page provides a detailed reference of all environment variables supported by Sourcebot. If you're just looking to get up and running, we recommend starting with the [deployment guide](/docs/deployment-guide) instead.</Note>
@@ -71,3 +70,6 @@ The following environment variables allow you to configure your Sourcebot deploy
7170
| `REVIEW_AGENT_LOGGING_ENABLED` | `true` | <p>Enables/disables logging for the review agent. Logs are saved in `DATA_CACHE_DIR/review-agent`</p> |
7271
| `REVIEW_AGENT_REVIEW_COMMAND` | `review` | <p>The command used to trigger a code review by the review agent.</p> |
7372

73+
### Overriding environment variables from the config
74+
75+
You can override environment variables from the config file by using the `environmentOverrides` property. See [this doc](/docs/configuration/config-file#overriding-environment-variables-from-the-config) for more info.

docs/docs/connections/ado-cloud.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
8686
Azure Devops Cloud requires you to provide a PAT in order to index your repositories. To learn how to create PAT, check out the [Azure Devops docs](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows).
8787
Sourcebot needs the `Read` access for the `Code` scope in order to find and clone your repos.
8888

89-
Next, provide the access token via an environment variable which is referenced in the `token` property:
89+
Next, provide the access [token](/docs/configuration/config-file#tokens) via an environment variable which is referenced in the `token` property:
9090

9191
<Tabs>
9292
<Tab title="Environment Variable">

docs/docs/connections/ado-server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
100100
Azure Devops Server requires you to provide a PAT in order to index your repositories. To learn how to create PAT, check out the [Azure Devops docs](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows).
101101
Sourcebot needs the `Read` access for the `Code` scope in order to find and clone your repos.
102102

103-
Next, provide the access token via an environment variable which is referenced in the `token` property:
103+
Next, provide the access [token](/docs/configuration/config-file#tokens) via an environment variable which is referenced in the `token` property:
104104

105105
<Tabs>
106106
<Tab title="Environment Variable">

docs/docs/connections/bitbucket-cloud.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
7878

7979
## Authenticating with Bitbucket Cloud
8080

81-
In order to index private repositories, you'll need to provide authentication credentials. You can do this using an `App Password` or an `Access Token`
81+
In order to index private repositories, you'll need to provide authentication credentials via a [token](/docs/configuration/config-file#tokens). You can do this using an `App Password` or an `Access Token`
8282

8383
<Tabs>
8484
<Tab title="App Password">

docs/docs/connections/bitbucket-data-center.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
7070

7171
## Authenticating with Bitbucket Data Center
7272

73-
In order to index private repositories, you'll need to provide an access token to Sourcebot.
73+
In order to index private repositories, you'll need to provide an access token to Sourcebot via a [token](/docs/configuration/config-file#tokens).
7474

7575
Create an access token for the desired scope (repo, project, or workspace). Visit the official [Bitbucket Data Center docs](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html)
7676
for more info.

docs/docs/connections/gitea.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ In order to index private repositories, you'll need to generate a Gitea access t
8181

8282
![Gitea Access token creation](/images/gitea_pat_creation.png)
8383

84-
Next, provide the access token via an environment variable which is referenced in the `token` property:
84+
Next, provide the access token via an environment variable [token](/docs/configuration/config-file#tokens) which is referenced in the `token` property:
8585

8686
<Tabs>
8787
<Tab title="Environment Variable">

docs/docs/connections/github.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ In order to index private repositories, you'll need to generate a access token a
128128
</Accordion>
129129
</AccordionGroup>
130130

131-
Next, provide the access token via an environment variable which is referenced in the `token` property:
131+
Next, provide the access token via an environment variable [token](/docs/configuration/config-file#tokens) which is referenced in the `token` property:
132132

133133
<Tabs>
134134
<Tab title="Environment Variable">

docs/docs/connections/gitlab.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ In order to index private projects, you'll need to generate a GitLab Personal Ac
116116

117117
![GitLab PAT Scope](/images/gitlab_pat_scopes.png)
118118

119-
Next, provide the PAT via an environment variable which is referenced in the `token` property:
119+
Next, provide the PAT via an environment variable [token](/docs/configuration/config-file#tokens) which is referenced in the `token` property:
120120

121121
<Tabs>
122122
<Tab title="Environment Variable">
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{/* THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY! */}
2+
```json
3+
{
4+
"type": "object",
5+
"description": "Environment variable overrides.",
6+
"name": "EnvironmentOverrides",
7+
"not": {
8+
"$comment": "List of environment variables that are not allowed to be overridden.",
9+
"anyOf": [
10+
{
11+
"required": [
12+
"CONFIG_PATH"
13+
]
14+
}
15+
]
16+
},
17+
"patternProperties": {
18+
"^[a-zA-Z0-9_-]+$": {
19+
"oneOf": [
20+
{
21+
"type": "object",
22+
"properties": {
23+
"type": {
24+
"const": "token"
25+
},
26+
"value": {
27+
"anyOf": [
28+
{
29+
"type": "object",
30+
"properties": {
31+
"env": {
32+
"type": "string",
33+
"description": "The name of the environment variable that contains the token."
34+
}
35+
},
36+
"required": [
37+
"env"
38+
],
39+
"additionalProperties": false
40+
},
41+
{
42+
"type": "object",
43+
"properties": {
44+
"googleCloudSecret": {
45+
"type": "string",
46+
"description": "The resource name of a Google Cloud secret. Must be in the format `projects/<project-id>/secrets/<secret-name>/versions/<version-id>`. See https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets"
47+
}
48+
},
49+
"required": [
50+
"googleCloudSecret"
51+
],
52+
"additionalProperties": false
53+
}
54+
]
55+
}
56+
},
57+
"required": [
58+
"type",
59+
"value"
60+
],
61+
"additionalProperties": false
62+
},
63+
{
64+
"type": "object",
65+
"properties": {
66+
"type": {
67+
"const": "string"
68+
},
69+
"value": {
70+
"type": "string"
71+
}
72+
},
73+
"required": [
74+
"type",
75+
"value"
76+
],
77+
"additionalProperties": false
78+
},
79+
{
80+
"type": "object",
81+
"properties": {
82+
"type": {
83+
"const": "number"
84+
},
85+
"value": {
86+
"type": "number"
87+
}
88+
},
89+
"required": [
90+
"type",
91+
"value"
92+
],
93+
"additionalProperties": false
94+
},
95+
{
96+
"type": "object",
97+
"properties": {
98+
"type": {
99+
"const": "boolean"
100+
},
101+
"value": {
102+
"type": "boolean"
103+
}
104+
},
105+
"required": [
106+
"type",
107+
"value"
108+
],
109+
"additionalProperties": false
110+
}
111+
]
112+
}
113+
}
114+
}
115+
```

0 commit comments

Comments
 (0)