38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
// Sourcegraph settings for code intelligence integration
|
|
var Sourcegraph = struct {
|
|
Enabled bool
|
|
URL string
|
|
AccessToken string
|
|
SkipTLSVerify bool
|
|
Timeout int // request timeout in seconds
|
|
CacheTTL int // cache time-to-live in seconds
|
|
SyncOnPush bool
|
|
}{
|
|
Enabled: false,
|
|
Timeout: 5,
|
|
CacheTTL: 300,
|
|
SyncOnPush: true,
|
|
SkipTLSVerify: false,
|
|
}
|
|
|
|
func loadSourcegraphFrom(rootCfg ConfigProvider) {
|
|
sec := rootCfg.Section("sourcegraph")
|
|
Sourcegraph.Enabled = sec.Key("ENABLED").MustBool(false)
|
|
Sourcegraph.URL = sec.Key("URL").MustString("")
|
|
Sourcegraph.AccessToken = sec.Key("ACCESS_TOKEN").MustString("")
|
|
Sourcegraph.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool(false)
|
|
Sourcegraph.Timeout = sec.Key("TIMEOUT").MustInt(5)
|
|
Sourcegraph.CacheTTL = sec.Key("CACHE_TTL").MustInt(300)
|
|
Sourcegraph.SyncOnPush = sec.Key("SYNC_ON_PUSH").MustBool(true)
|
|
|
|
// Validate: if enabled, URL must be set
|
|
if Sourcegraph.Enabled && Sourcegraph.URL == "" {
|
|
Sourcegraph.Enabled = false
|
|
}
|
|
}
|