Skip to content

Commit 175fcfe

Browse files
author
Stephen Gutekanst
committed
add support for specifying endpoint via environment + add docs
Fixes #38
1 parent 5a862ea commit 175fcfe

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ Consult `src -h` and `src api -h` for usage information.
5858
Some Sourcegraph instances will be configured to require authentication. You can do so via the environment:
5959

6060
```sh
61-
SRC_ACCESS_TOKEN="secret" src ...
61+
SRC_ENDPOINT=https://sourcegraph.example.com SRC_ACCESS_TOKEN="secret" src ...
6262
```
6363

6464
Or via the configuration file (`~/src-config.json`):
6565

6666
```sh
67-
{"accessToken": "secret"}
67+
{"accessToken": "secret", "endpoint": "https://sourcegraph.example.com"}
6868
```
6969

7070
See `src -h` for more information on specifying access tokens.

cmd/src/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ func readConfig() (*config, error) {
9191
if *endpoint != "" {
9292
cfg.Endpoint = strings.TrimSuffix(*endpoint, "/")
9393
}
94+
if cfg.Endpoint == "" {
95+
if endpoint := os.Getenv("SRC_ENDPOINT"); endpoint != "" {
96+
cfg.Endpoint = endpoint
97+
}
98+
}
9499
if cfg.Endpoint == "" {
95100
cfg.Endpoint = "https://sourcegraph.com"
96101
}

0 commit comments

Comments
 (0)