Skip to content

Commit c3bf70a

Browse files
committed
move DefaultEndpointConfigured to be attr on struct
1 parent 3608a6e commit c3bf70a

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

cmd/src/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Examples:
6666

6767
if hasEndpointURLConflict {
6868
// If the default is configured it means SRC_ENDPOINT is not set
69-
if DefaultEndpointConfigured(cfg) {
69+
if cfg.usingDefaultEndpoint {
7070
fmt.Fprintf(os.Stderr, "⚠️ Warning: No SRC_ENDPOINT is configured in the environment. Logging in using %q.\n", loginEndpointURL)
7171
fmt.Fprintf(os.Stderr, "\n💡 Tip: To use this endpoint in your shell, run:\n\n export SRC_ENDPOINT=%s\n\nNOTE: By default src will use %q if SRC_ENDPOINT is not set.\n", loginEndpointURL, SGDotComEndpoint)
7272
} else {

cmd/src/main.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ var cfg *config
143143

144144
// config holds the resolved configuration used at runtime.
145145
type config struct {
146-
accessToken string
147-
additionalHeaders map[string]string
148-
proxyURL *url.URL
149-
proxyPath string
150-
configFilePath string
151-
endpointURL *url.URL // always non-nil; defaults to https://sourcegraph.com via readConfig
152-
inCI bool
146+
accessToken string
147+
additionalHeaders map[string]string
148+
proxyURL *url.URL
149+
proxyPath string
150+
configFilePath string
151+
endpointURL *url.URL // always non-nil; defaults to https://sourcegraph.com via readConfig
152+
usingDefaultEndpoint bool
153+
inCI bool
153154
}
154155

155156
// configFromFile holds the config as read from the config file,
@@ -273,6 +274,7 @@ func readConfig() (*config, error) {
273274
}
274275
if endpointStr == "" {
275276
endpointStr = SGDotComEndpoint
277+
cfg.usingDefaultEndpoint = true
276278
}
277279
if envProxy != "" {
278280
proxyStr = envProxy
@@ -350,15 +352,6 @@ func isCI() bool {
350352
return ok && value != ""
351353
}
352354

353-
func DefaultEndpointConfigured(cfg *config) bool {
354-
_, ok := os.LookupEnv("SRC_ENDPOINT")
355-
if ok {
356-
return false
357-
}
358-
return cfg.endpointURL != nil && cfg.endpointURL.String() == SGDotComEndpoint
359-
360-
}
361-
362355
// isValidUnixSocket checks if the given path is a valid Unix socket.
363356
//
364357
// Parameters:

0 commit comments

Comments
 (0)