src-cli icon indicating copy to clipboard operation
src-cli copied to clipboard

Env var SRC_ENDPOINT is ignored when config file exists

Open sqs opened this issue 5 years ago • 5 comments

If ~/src-config.json exists, the env var SRC_ENDPOINT is ignored (see https://sourcegraph.com/github.com/sourcegraph/src-cli@6f6674f8e67e380efe64cd53662f342cd4604a74/-/blob/cmd/src/main.go#L106). This is confusing. Also, SRC_ACCESS_TOKEN behaves in the opposite way; it overrides the value set in the config file.

I believe the ideal behavior is:

  • Both env vars override the config file.
  • If a config file exists, either zero or both env vars must be specified. It is an error if only one is specified. This is to avoid confusion; we never merge config from the file and env vars.

Reported by @nicksnyder in https://sourcegraph.slack.com/archives/CMMTWQQ49/p1591657309056300.

sqs avatar Jun 09 '20 06:06 sqs

@ryanslade Wasn't this fixed with your #205?

mrnugget avatar Jun 09 '20 07:06 mrnugget

No, that change only removed the documentation regarding the config file as a first step before removing support for it.

We also have the -endpoint flag. I think maybe we should remove that and then follow the rules set out by @sqs above.

I'm happy to take this as I worked on the code recently, assign it to me if you're happy with that.

ryanslade avatar Jun 09 '20 10:06 ryanslade

@sqs Are you happy with the above suggestion, specifically removing the -endpoint flag?

ryanslade avatar Jun 10 '20 07:06 ryanslade

Yep :+1:

sqs avatar Jun 10 '20 07:06 sqs

We need to keep the endpoint flag around for now as some of our LSIF actions depend on it.

I'll submit another PR that removes it from docs but still respects it.

I think the simplest way to do this is to follow the same logic as before but if the flag has been set it'll override both the config file and environment variables.

ryanslade avatar Jun 26 '20 15:06 ryanslade