mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 12:51:55 +00:00
remove more remannts of OSS build (#58253)
Removes: - doc mentions of OSS build - linters related to OSS/enterprise code - unused `osscmd` package and related definitions
This commit is contained in:
parent
8d4f86a9f1
commit
e5baad0ccd
@ -109,12 +109,6 @@ const config = {
|
||||
},
|
||||
],
|
||||
patterns: [
|
||||
{
|
||||
group: ['**/enterprise/*'],
|
||||
message: `The OSS product may not pull in any code from the enterprise codebase, to stay a 100% open-source program.
|
||||
|
||||
See https://handbook.sourcegraph.com/community/faq#is-all-of-sourcegraph-open-source for more information.`,
|
||||
},
|
||||
{
|
||||
group: ['@sourcegraph/branded/src/search-ui/experimental'],
|
||||
message:
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
|
||||
## Getting started
|
||||
|
||||
- [**Download Sourcegraph**](https://about.sourcegraph.com/app) for macOS and Linux
|
||||
- [Use Sourcegraph on the cloud or self-hosted](https://docs.sourcegraph.com/)
|
||||
- [Sourcegraph.com public code search](https://sourcegraph.com/search)
|
||||
|
||||
@ -64,6 +63,4 @@ The `doc` directory has additional documentation for developing and understandin
|
||||
|
||||
## License
|
||||
|
||||
This repository contains primarily non-OSS-licensed files, and some OSS licensed files (for example, IDE extensions). We maintain one repository rather than two separate repositories mainly for development convenience.
|
||||
|
||||
See the [LICENSE](LICENSE) for an explanation of how files are licensed.
|
||||
This repository contains primarily non-OSS-licensed files. See [LICENSE](LICENSE).
|
||||
|
||||
@ -42,7 +42,6 @@ SRCS = [
|
||||
".prettierignore",
|
||||
".env",
|
||||
".env.dotcom",
|
||||
".env.oss",
|
||||
"//client/wildcard:sass-breakpoints",
|
||||
"//client/wildcard:global-style-sources",
|
||||
"//client/web/dist/img:copy",
|
||||
@ -123,7 +122,6 @@ npm_link_all_packages(name = "node_modules")
|
||||
vite_bin.vite(
|
||||
name = "web-sveltekit",
|
||||
srcs = SRCS + BUILD_DEPS + CONFIGS,
|
||||
out_dirs= ["build"],
|
||||
args = [
|
||||
"build",
|
||||
"--force",
|
||||
@ -133,6 +131,7 @@ vite_bin.vite(
|
||||
env = {
|
||||
"BAZEL": "1",
|
||||
},
|
||||
out_dirs = ["build"],
|
||||
visibility = ["//client/web/dist:__pkg__"],
|
||||
# silent_on_success = False,
|
||||
)
|
||||
|
||||
@ -16,9 +16,8 @@ pnpm run -w generate
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
You can also build the OSS or dotcom version by running `pnpm run dev:oss` and
|
||||
`pnpm run dev:dotcom` respectively, but they don't really differ in
|
||||
functionality yet.
|
||||
You can also build the dotcom version by running `pnpm run dev:dotcom`, but it doesn't really differ
|
||||
in functionality yet.
|
||||
|
||||
The dev server can be accessed on http://localhost:5173. API requests and
|
||||
signin/signout are proxied to an actual Sourcegraph instance,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"dev:dotcom": "vite dev --mode=dotcom",
|
||||
"dev:oss": "vite dev --mode=oss",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test",
|
||||
|
||||
@ -27,8 +27,8 @@ const MERGE_BASE = execSync('git merge-base HEAD origin/main').toString().trim()
|
||||
let COMPARE_REV = ''
|
||||
|
||||
async function findFile(root: string, filename: string): Promise<string> {
|
||||
// file can be in one of 3 base paths
|
||||
const parts: string[] = ['oss', 'enterprise', '']
|
||||
// file can be in one of 2 base paths
|
||||
const parts: string[] = ['enterprise', '']
|
||||
const files = await Promise.all(
|
||||
parts.flatMap(async (dir: string) => {
|
||||
const filePath = path.join(root, dir, filename)
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
import { gql } from '@sourcegraph/http-client'
|
||||
|
||||
/**
|
||||
* NOTE: These fields are only available from an enterprise install, but are used to
|
||||
* surface batch changes information on the repo `TreePage`, which is available to both
|
||||
* OSS and enterprise
|
||||
*/
|
||||
export const REPO_CHANGESETS_STATS = gql`
|
||||
query RepoChangesetsStats($name: String!) {
|
||||
repository(name: $name) {
|
||||
|
||||
@ -7,6 +7,5 @@ export interface BrainDotProps {
|
||||
}
|
||||
|
||||
// This component is only a stub (hence the null body) that we overwrite in the enterprise
|
||||
// app. We define this here so we have a stable type to provide on initialization. The OSS
|
||||
// version simply never renders the code intel repository menu.
|
||||
// app. We define this here so we have a stable type to provide on initialization.
|
||||
export const BrainDot: React.FunctionComponent<BrainDotProps> = () => null
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
/**
|
||||
* Common props for code insights consumer components (the homepage, the directory page)
|
||||
* These props are needed for condition rendering of Code Insights and extension-like views.
|
||||
* For the enterprise version it's code insights + extension views and for the OSS version
|
||||
* it's extension views only.
|
||||
*/
|
||||
export interface CodeInsightsProps {
|
||||
codeInsightsEnabled?: boolean
|
||||
|
||||
@ -1,4 +1,13 @@
|
||||
import { FC, MutableRefObject, type SetStateAction, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import {
|
||||
type FC,
|
||||
type MutableRefObject,
|
||||
type SetStateAction,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
|
||||
import classNames from 'classnames'
|
||||
import BarChartIcon from 'mdi-react/BarChartIcon'
|
||||
@ -157,7 +166,6 @@ export const GlobalNavbar: React.FunctionComponent<React.PropsWithChildren<Globa
|
||||
}
|
||||
}, [showSearchBox, onNavbarQueryChange])
|
||||
|
||||
// CodeInsightsEnabled props controls insights appearance over OSS and Enterprise version
|
||||
const codeInsights = (codeInsightsEnabled && !isCodyApp && !isSourcegraphDotCom) ?? false
|
||||
|
||||
const { fuzzyFinderNavbar } = useFuzzyFinderFeatureFlags()
|
||||
|
||||
@ -345,8 +345,6 @@ export const StreamingSearchResults: FC<StreamingSearchResultsProps> = props =>
|
||||
|
||||
const hasResultsToAggregate = results?.state === 'complete' ? (results?.results.length ?? 0) > 0 : true
|
||||
|
||||
// Show aggregation panel only if we're in Enterprise versions and hide it in OSS and
|
||||
// when search doesn't have any matches
|
||||
const showAggregationPanel = searchAggregationEnabled && hasResultsToAggregate
|
||||
|
||||
const onDisableSmartSearch = useCallback(() => {
|
||||
|
||||
@ -15,7 +15,7 @@ export const PagePath = {
|
||||
*
|
||||
* Proposal:
|
||||
*
|
||||
* 1. Create storm folder for OSS and enterprise version.
|
||||
* 1. Create storm folder
|
||||
* 2. Create routes constant that re-uses existing routes and one by one replaces old ones with new components.
|
||||
* 3. "Upgraded" components are moved into the `storm` project.
|
||||
*
|
||||
|
||||
@ -10,8 +10,8 @@ go_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//cmd/blobstore/shared",
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -3,11 +3,11 @@ package main // import "github.com/sourcegraph/sourcegraph/cmd/blobstore"
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/blobstore/shared"
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
osscmd.SingleServiceMainOSS(shared.Service)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ var sentryDSN = env.Get("CODY_GATEWAY_SENTRY_DSN", "", "Sentry DSN")
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.Config{}, svcmain.OutOfBandConfiguration{
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.OutOfBandConfiguration{
|
||||
Logging: func() conf.LogSinksSource {
|
||||
if sentryDSN == "" {
|
||||
return nil
|
||||
|
||||
@ -6,9 +6,7 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
var config = svcmain.Config{}
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMain(shared.Service, config)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -91,6 +91,7 @@ go_test(
|
||||
"//internal/api",
|
||||
"//internal/conf",
|
||||
"//internal/database",
|
||||
"//internal/database/basestore",
|
||||
"//internal/database/dbmocks",
|
||||
"//internal/database/dbtest",
|
||||
"//internal/encryption",
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/conf"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/dbmocks"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/dbtest"
|
||||
"github.com/sourcegraph/sourcegraph/internal/extsvc"
|
||||
@ -286,7 +287,32 @@ func TestSendUserEmailOnTokenChange(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type noopAuthzStore struct{}
|
||||
|
||||
func (*noopAuthzStore) GrantPendingPermissions(_ context.Context, _ *database.GrantPendingPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) AuthorizedRepos(_ context.Context, _ *database.AuthorizedReposArgs) ([]*types.Repo, error) {
|
||||
return []*types.Repo{}, nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) RevokeUserPermissions(_ context.Context, _ *database.RevokeUserPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) RevokeUserPermissionsList(_ context.Context, _ []*database.RevokeUserPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestUserEmailsAddRemove(t *testing.T) {
|
||||
database.AuthzWith = func(basestore.ShareableStore) database.AuthzStore {
|
||||
return &noopAuthzStore{}
|
||||
}
|
||||
defer func() {
|
||||
database.AuthzWith = nil
|
||||
}()
|
||||
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
ctx := context.Background()
|
||||
@ -356,6 +382,13 @@ func TestUserEmailsAddRemove(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserEmailsSetPrimary(t *testing.T) {
|
||||
database.AuthzWith = func(basestore.ShareableStore) database.AuthzStore {
|
||||
return &noopAuthzStore{}
|
||||
}
|
||||
defer func() {
|
||||
database.AuthzWith = nil
|
||||
}()
|
||||
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
ctx := context.Background()
|
||||
@ -397,6 +430,13 @@ func TestUserEmailsSetPrimary(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserEmailsSetVerified(t *testing.T) {
|
||||
database.AuthzWith = func(basestore.ShareableStore) database.AuthzStore {
|
||||
return &noopAuthzStore{}
|
||||
}
|
||||
defer func() {
|
||||
database.AuthzWith = nil
|
||||
}()
|
||||
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
ctx := context.Background()
|
||||
|
||||
@ -10,12 +10,7 @@ import (
|
||||
// the GraphQL resolver for the GraphQL type ProductLicenseInfo.
|
||||
//
|
||||
// Exactly 1 of its return values must be non-nil.
|
||||
//
|
||||
// It is overridden in non-OSS builds to return information about the actual product subscription in
|
||||
// use.
|
||||
var GetConfiguredProductLicenseInfo = func() (*ProductLicenseInfo, error) {
|
||||
return nil, nil // OSS builds have no license
|
||||
}
|
||||
var GetConfiguredProductLicenseInfo func() (*ProductLicenseInfo, error)
|
||||
|
||||
var IsFreePlan = func(*ProductLicenseInfo) bool {
|
||||
return true
|
||||
|
||||
@ -19,7 +19,7 @@ func main() {
|
||||
if os.Getenv("WEB_BUILDER_DEV_SERVER") == "1" {
|
||||
assets.UseDevAssetsProvider()
|
||||
}
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.Config{}, svcmain.OutOfBandConfiguration{
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.OutOfBandConfiguration{
|
||||
// use a switchable config here so we can switch it out for a proper conf client
|
||||
// once we can use it after autoupgrading
|
||||
Logging: conf.NewLogsSinksSource(shared.SwitchableSiteConfig()),
|
||||
|
||||
@ -11,8 +11,8 @@ go_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//cmd/gitserver/shared",
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -3,11 +3,11 @@ package main // import "github.com/sourcegraph/sourcegraph/cmd/gitserver"
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/gitserver/shared"
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
osscmd.SingleServiceMainOSS(shared.Service)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ var sentryDSN = env.Get("PINGS_SENTRY_DSN", "", "Sentry DSN")
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.Config{}, svcmain.OutOfBandConfiguration{
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.OutOfBandConfiguration{
|
||||
Logging: func() conf.LogSinksSource {
|
||||
if sentryDSN == "" {
|
||||
return nil
|
||||
|
||||
@ -6,9 +6,7 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
var config = svcmain.Config{}
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMain(shared.Service, config)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ go_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//cmd/repo-updater/shared",
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -4,11 +4,11 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/repo-updater/shared"
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
osscmd.SingleServiceMainOSS(shared.Service)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ go_library(
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//cmd/searcher/shared",
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -4,11 +4,11 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/searcher/shared"
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
osscmd.SingleServiceMainOSS(shared.Service)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -15,13 +15,13 @@ go_library(
|
||||
"//cmd/precise-code-intel-worker/shared",
|
||||
"//cmd/repo-updater/shared",
|
||||
"//cmd/searcher/shared",
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//cmd/symbols/shared",
|
||||
"//cmd/worker/shared",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service",
|
||||
"//internal/service/localcodehost",
|
||||
"//internal/service/servegit",
|
||||
"//internal/service/svcmain",
|
||||
"//ui/assets",
|
||||
],
|
||||
)
|
||||
|
||||
@ -3,11 +3,11 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/localcodehost"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/servegit"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
|
||||
blobstore_shared "github.com/sourcegraph/sourcegraph/cmd/blobstore/shared"
|
||||
embeddings_shared "github.com/sourcegraph/sourcegraph/cmd/embeddings/shared"
|
||||
@ -45,5 +45,5 @@ func main() {
|
||||
if os.Getenv("WEB_BUILDER_DEV_SERVER") == "1" {
|
||||
assets.UseDevAssetsProvider()
|
||||
}
|
||||
osscmd.MainOSS(services, os.Args)
|
||||
svcmain.Main(services, os.Args)
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "osscmd",
|
||||
srcs = ["osscmd.go"],
|
||||
importpath = "github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//internal/authz",
|
||||
"//internal/service",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
@ -1,28 +0,0 @@
|
||||
// Package osscmd defines entrypoint functions for the OSS build of Sourcegraph's single-binary
|
||||
// distribution. It is invoked by all OSS commands' main functions.
|
||||
package osscmd
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
var config = svcmain.Config{
|
||||
AfterConfigure: func() {
|
||||
// Set dummy authz provider to unblock channel for checking permissions in GraphQL APIs.
|
||||
// See https://github.com/sourcegraph/sourcegraph/issues/3847 for details.
|
||||
authz.SetProviders(true, []authz.Provider{})
|
||||
},
|
||||
}
|
||||
|
||||
// MainOSS is called from the `main` function of the `cmd/sourcegraph` command.
|
||||
func MainOSS(services []service.Service, args []string) {
|
||||
svcmain.Main(services, config, args)
|
||||
}
|
||||
|
||||
// SingleServiceMainOSS is called from the `main` function of a command in the OSS build
|
||||
// to start a single service (such as frontend or gitserver).
|
||||
func SingleServiceMainOSS(service service.Service) {
|
||||
svcmain.SingleServiceMain(service, config)
|
||||
}
|
||||
@ -8,9 +8,7 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
var config = svcmain.Config{}
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMain(shared.Service, config)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ var sentryDSN = env.Get("TELEMETRY_GATEWAY_SENTRY_DSN", "", "Sentry DSN")
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.Config{}, svcmain.OutOfBandConfiguration{
|
||||
svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.OutOfBandConfiguration{
|
||||
Logging: func() conf.LogSinksSource {
|
||||
if sentryDSN == "" {
|
||||
return nil
|
||||
|
||||
@ -10,9 +10,9 @@ go_library(
|
||||
importpath = "github.com/sourcegraph/sourcegraph/cmd/worker",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//cmd/sourcegraph/osscmd",
|
||||
"//cmd/worker/shared",
|
||||
"//internal/sanitycheck",
|
||||
"//internal/service/svcmain",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/sourcegraph/osscmd"
|
||||
"github.com/sourcegraph/sourcegraph/cmd/worker/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/sanitycheck"
|
||||
"github.com/sourcegraph/sourcegraph/internal/service/svcmain"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sanitycheck.Pass()
|
||||
osscmd.SingleServiceMainOSS(shared.Service)
|
||||
svcmain.SingleServiceMain(shared.Service)
|
||||
}
|
||||
|
||||
@ -19,14 +19,12 @@ go env
|
||||
CHECKS=(
|
||||
./gofmt.sh
|
||||
./template-inlines.sh
|
||||
./go-enterprise-import.sh
|
||||
./go-dbconn-import.sh
|
||||
./go-lint.sh
|
||||
./no-localhost-guard.sh
|
||||
./bash-syntax.sh
|
||||
./shfmt.sh
|
||||
./shellcheck.sh
|
||||
./ts-enterprise-import.sh
|
||||
./submodule.sh
|
||||
)
|
||||
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script ensures OSS sourcegraph does not import enterprise sourcegraph.
|
||||
|
||||
echo "--- go enterprise import"
|
||||
|
||||
trap "echo ^^^ +++" ERR
|
||||
|
||||
set -euxf -o pipefail
|
||||
|
||||
prefix=github.com/sourcegraph/sourcegraph/enterprise
|
||||
# shellcheck disable=SC2016
|
||||
template='{{with $pkg := .}}{{ range $pkg.Imports }}{{ printf "%s imports %s\n" $pkg.ImportPath .}}{{end}}{{end}}'
|
||||
|
||||
if go list ./../../... |
|
||||
grep -v "^$prefix" |
|
||||
xargs go list -f "$template" |
|
||||
grep "$prefix"; then
|
||||
echo "Error: OSS is not allowed to import enterprise"
|
||||
echo "^^^ +++"
|
||||
exit 1
|
||||
fi
|
||||
@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
echo "--- no enterprise import in OSS web guard"
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
|
||||
set +e
|
||||
IMPORT_MATCHES=$(
|
||||
git grep -e "import .*'\S*\/enterprise\S*'" -e "from .*'\S*\/enterprise\S*'" \
|
||||
':(exclude)client/web/src/enterprise' \
|
||||
'client/web/src'
|
||||
)
|
||||
set -e
|
||||
|
||||
if [ -n "$IMPORT_MATCHES" ]; then
|
||||
echo
|
||||
echo "Error: Found imports from enterprise codebase in client/web/src/(!enterprise)"
|
||||
# shellcheck disable=SC2001
|
||||
echo "$IMPORT_MATCHES" | sed 's/^/ /'
|
||||
|
||||
cat <<EOF
|
||||
Importing from enterprise in non-enterprise modules is forbidden. The OSS product may not
|
||||
pull in any code from the enterprise codebase, to stay a 100% open-source program. See
|
||||
this page for more information:
|
||||
https://handbook.sourcegraph.com/community/faq#is-all-of-sourcegraph-open-source
|
||||
|
||||
To make this check pass, remove that import. Usually this works by:
|
||||
- Pulling shared code out of the enterprise directory.
|
||||
- Moving an enterprise-only component that is not in the client/web/src/enterprise subdirectory to there.
|
||||
- Building a way to inject in the client/web/src/enterprise/main.tsx. See routes for an example.
|
||||
EOF
|
||||
echo "^^^ +++"
|
||||
exit 1
|
||||
fi
|
||||
@ -40,7 +40,6 @@ This command ensures the following lint passes. Violations of the lint rules wil
|
||||
|
||||
- **NoBinarySpecificSharedCode**: Report shared packages that are imported only by a single command
|
||||
- **NoDeadPackages**: Report unused packages (except for library code and main packages)
|
||||
- **NoEnterpriseImportsFromOSS**: Report packages that illegally import enterprise code
|
||||
- **NoLooseCommands**: Report main packages outside of known command roots
|
||||
- **NoReachingIntoCommands**: Report packages that import code from an unrelated command
|
||||
- **NoUnusedSharedCommandCode**: Report packages that could be moved into an internal package
|
||||
|
||||
@ -6,7 +6,6 @@ go_library(
|
||||
"lint.go",
|
||||
"no_binary_specific_shared_code.go",
|
||||
"no_dead_packages.go",
|
||||
"no_enterprise_imports_from_oss.go",
|
||||
"no_loose_commands.go",
|
||||
"no_reaching_into_commands.go",
|
||||
"no_unused_shared_command_code.go",
|
||||
|
||||
@ -19,7 +19,6 @@ type lintError struct {
|
||||
var lintsByName = map[string]Lint{
|
||||
"NoBinarySpecificSharedCode": NoBinarySpecificSharedCode,
|
||||
"NoDeadPackages": NoDeadPackages,
|
||||
"NoEnterpriseImportsFromOSS": NoEnterpriseImportsFromOSS,
|
||||
"NoLooseCommands": NoLooseCommands,
|
||||
"NoReachingIntoCommands": NoReachingIntoCommands,
|
||||
"NoUnusedSharedCommandCode": NoUnusedSharedCommandCode,
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
package lints
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/dev/depgraph/internal/graph"
|
||||
)
|
||||
|
||||
// NoEnterpriseImportsFromOSS returns an error for each non-enterprise package that
|
||||
// imports an enterprise package.
|
||||
func NoEnterpriseImportsFromOSS(graph *graph.DependencyGraph) []lintError {
|
||||
return mapPackageErrors(graph, func(pkg string) (lintError, bool) {
|
||||
if isEnterprise(pkg) {
|
||||
return lintError{}, false
|
||||
}
|
||||
|
||||
var imports []string
|
||||
for _, dependency := range graph.Dependencies[pkg] {
|
||||
if isEnterprise(dependency) {
|
||||
imports = append(imports, dependency)
|
||||
}
|
||||
}
|
||||
if len(imports) == 0 {
|
||||
return lintError{}, false
|
||||
}
|
||||
|
||||
return makeNoEnterpriseImportsFromOSSError(pkg, imports), true
|
||||
})
|
||||
}
|
||||
|
||||
func makeNoEnterpriseImportsFromOSSError(pkg string, imports []string) lintError {
|
||||
items := make([]string, 0, len(imports))
|
||||
for _, importer := range imports {
|
||||
items = append(items, fmt.Sprintf("\t- %s", importer))
|
||||
}
|
||||
|
||||
return lintError{
|
||||
pkg: pkg,
|
||||
message: []string{
|
||||
fmt.Sprintf("This package imports the following %d enterprise packages:\n%s", len(items), strings.Join(items, "\n")),
|
||||
"To resolve, move this package into enterprise/.",
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,6 @@ import (
|
||||
)
|
||||
|
||||
type CheckArgs struct {
|
||||
Teammate bool
|
||||
|
||||
ConfigFile string
|
||||
ConfigOverwriteFile string
|
||||
DisableOverwrite bool
|
||||
|
||||
@ -18,7 +18,6 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
var testArgs = CheckArgs{
|
||||
Teammate: false,
|
||||
ConfigFile: "../../../sg.config.yaml",
|
||||
ConfigOverwriteFile: "../../../sg.config.overwrite.yaml",
|
||||
}
|
||||
|
||||
@ -58,15 +58,6 @@ func enableOnlyInSourcegraphRepo() check.EnableFunc[CheckArgs] {
|
||||
}
|
||||
}
|
||||
|
||||
func enableForTeammatesOnly() check.EnableFunc[CheckArgs] {
|
||||
return func(ctx context.Context, args CheckArgs) error {
|
||||
if !args.Teammate {
|
||||
return errors.New("disabled if not a Sourcegraph teammate")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func disableInCI() check.EnableFunc[CheckArgs] {
|
||||
return func(ctx context.Context, args CheckArgs) error {
|
||||
// Docker is quite funky in CI
|
||||
|
||||
@ -330,7 +330,6 @@ YOU NEED TO RESTART 'sg setup' AFTER RUNNING THIS COMMAND!`,
|
||||
{
|
||||
Name: "Cloud services",
|
||||
DependsOn: []string{depsHomebrew},
|
||||
Enabled: enableForTeammatesOnly(),
|
||||
Checks: []*dependency{
|
||||
dependencyGcloud(),
|
||||
},
|
||||
|
||||
@ -31,13 +31,9 @@ See here on how to set that up:
|
||||
|
||||
https://docs.github.com/en/authentication/connecting-to-github-with-ssh`,
|
||||
Check: func(ctx context.Context, out *std.Output, args CheckArgs) error {
|
||||
if args.Teammate {
|
||||
return check.CommandOutputContains(
|
||||
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -T git@github.com",
|
||||
"successfully authenticated")(ctx)
|
||||
}
|
||||
// otherwise, we don't need auth set up at all, since everything is OSS
|
||||
return nil
|
||||
return check.CommandOutputContains(
|
||||
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -T git@github.com",
|
||||
"successfully authenticated")(ctx)
|
||||
},
|
||||
// TODO we might be able to automate this fix
|
||||
},
|
||||
@ -56,12 +52,7 @@ https://docs.github.com/en/authentication/connecting-to-github-with-ssh`,
|
||||
return nil
|
||||
},
|
||||
Fix: func(ctx context.Context, cio check.IO, args CheckArgs) error {
|
||||
var cmd *run.Command
|
||||
if args.Teammate {
|
||||
cmd = run.Cmd(ctx, `git clone git@github.com:sourcegraph/sourcegraph.git`)
|
||||
} else {
|
||||
cmd = run.Cmd(ctx, `git clone https://github.com/sourcegraph/sourcegraph.git`)
|
||||
}
|
||||
cmd := run.Cmd(ctx, `git clone git@github.com:sourcegraph/sourcegraph.git`)
|
||||
return cmd.Run().StreamLines(cio.Write)
|
||||
},
|
||||
},
|
||||
@ -78,9 +69,7 @@ so they sit alongside each other, like this:
|
||||
/dir
|
||||
|-- dev-private
|
||||
+-- sourcegraph
|
||||
|
||||
NOTE: You can ignore this if you're not a Sourcegraph teammate.`,
|
||||
Enabled: enableForTeammatesOnly(),
|
||||
`,
|
||||
Check: func(ctx context.Context, out *std.Output, args CheckArgs) error {
|
||||
ok, err := pathExists("dev-private")
|
||||
if ok && err == nil {
|
||||
|
||||
@ -268,7 +268,6 @@ YOU NEED TO RESTART 'sg setup' AFTER RUNNING THIS COMMAND!`,
|
||||
{
|
||||
Name: "Cloud services",
|
||||
DependsOn: []string{depsBaseUtilities},
|
||||
Enabled: enableForTeammatesOnly(),
|
||||
Checks: []*dependency{
|
||||
dependencyGcloud(),
|
||||
},
|
||||
|
||||
@ -29,9 +29,9 @@ checks:
|
||||
failMessage: "Failed to run 'docker version'. Please make sure Docker is running."
|
||||
|
||||
commandsets:
|
||||
oss:
|
||||
web:
|
||||
- frontend
|
||||
- gitserver
|
||||
- caddy
|
||||
enterprise:
|
||||
checks:
|
||||
- docker
|
||||
@ -58,9 +58,9 @@ commandsets:
|
||||
},
|
||||
},
|
||||
Commandsets: map[string]*Commandset{
|
||||
"oss": {
|
||||
Name: "oss",
|
||||
Commands: []string{"frontend", "gitserver"},
|
||||
"web": {
|
||||
Name: "web",
|
||||
Commands: []string{"frontend", "caddy"},
|
||||
},
|
||||
"enterprise": {
|
||||
Name: "enterprise",
|
||||
|
||||
@ -6,7 +6,6 @@ go_library(
|
||||
srcs = [
|
||||
"buf.go",
|
||||
"client.go",
|
||||
"enterprise.go",
|
||||
"go_checks.go",
|
||||
"godirective.go",
|
||||
"gogenerate.go",
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
package linters
|
||||
|
||||
var (
|
||||
goEnterpriseImport = runScript("Go enterprise imports in OSS", "dev/check/go-enterprise-import.sh")
|
||||
tsEnterpriseImport = runScript("Typescript imports in OSS", "dev/check/ts-enterprise-import.sh")
|
||||
)
|
||||
@ -38,7 +38,6 @@ var Targets = []Target{
|
||||
Checks: []*linter{
|
||||
goGenerateLinter,
|
||||
goDBConnImport,
|
||||
goEnterpriseImport,
|
||||
noLocalHost,
|
||||
lintGoDirectives(),
|
||||
lintLoggingLibraries(),
|
||||
@ -73,7 +72,6 @@ var Targets = []Target{
|
||||
Name: "client",
|
||||
Description: "Check client code for linting errors, forbidden imports, etc",
|
||||
Checks: []*linter{
|
||||
tsEnterpriseImport,
|
||||
inlineTemplates,
|
||||
runScript("pnpm dedupe", "dev/check/pnpm-deduplicate.sh"),
|
||||
// we only run this linter locally, since on CI it has it's own job
|
||||
|
||||
@ -105,17 +105,6 @@ commandsets:
|
||||
env:
|
||||
SOURCEGRAPHDOTCOM_MODE: true
|
||||
|
||||
oss:
|
||||
noDevPrivate: true
|
||||
checks:
|
||||
- docker
|
||||
- redis
|
||||
commands:
|
||||
- frontend
|
||||
- repo-updater
|
||||
- gitserver
|
||||
- web
|
||||
|
||||
tests:
|
||||
# These can be run with `sg test [name]`
|
||||
# Every command is run from the repository root.
|
||||
|
||||
@ -31,10 +31,6 @@ var setupCommand = &cli.Command{
|
||||
Aliases: []string{"f"},
|
||||
Usage: "Fix all checks",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "oss",
|
||||
Usage: "Omit Sourcegraph-teammate-specific setup",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "skip-pre-commit",
|
||||
Usage: "Skip overwriting pre-commit.com installation",
|
||||
@ -67,7 +63,6 @@ var setupCommand = &cli.Command{
|
||||
setup.RunPostFixChecks = true
|
||||
|
||||
args := dependencies.CheckArgs{
|
||||
Teammate: !cmd.Bool("oss"),
|
||||
ConfigFile: configFile,
|
||||
ConfigOverwriteFile: configOverwriteFile,
|
||||
DisableOverwrite: disableOverwrite,
|
||||
@ -86,15 +81,6 @@ var setupCommand = &cli.Command{
|
||||
return setup.Fix(cmd.Context, args)
|
||||
|
||||
default:
|
||||
// Prompt for details if flags are not set
|
||||
if !cmd.IsSet("oss") {
|
||||
std.Out.Promptf("Are you a Sourcegraph teammate? (y/n)")
|
||||
var s string
|
||||
if _, err := fmt.Scan(&s); err != nil {
|
||||
return err
|
||||
}
|
||||
args.Teammate = s == "y"
|
||||
}
|
||||
return setup.Interactive(cmd.Context, args)
|
||||
}
|
||||
},
|
||||
|
||||
@ -77,7 +77,7 @@ sg start batches
|
||||
sg start --debug=gitserver --error=enterprise-worker,enterprise-frontend enterprise
|
||||
|
||||
# View configuration for a commandset
|
||||
sg start -describe oss
|
||||
sg start -describe single-program
|
||||
`,
|
||||
Category: category.Dev,
|
||||
Flags: []cli.Flag{
|
||||
@ -238,8 +238,7 @@ func startExec(ctx *cli.Context) error {
|
||||
if !exists {
|
||||
std.Out.WriteLine(output.Styled(output.StyleWarning, "ERROR: dev-private repository not found!"))
|
||||
std.Out.WriteLine(output.Styledf(output.StyleWarning, "It's expected to exist at: %s", devPrivatePath))
|
||||
std.Out.WriteLine(output.Styled(output.StyleWarning, "If you're not a Sourcegraph teammate you probably want to run: sg start oss"))
|
||||
std.Out.WriteLine(output.Styled(output.StyleWarning, "If you're a Sourcegraph teammate, see the documentation for how to get set up: https://docs.sourcegraph.com/dev/setup/quickstart#run-sg-setup"))
|
||||
std.Out.WriteLine(output.Styled(output.StyleWarning, "See the documentation for how to get set up: https://docs.sourcegraph.com/dev/setup/quickstart#run-sg-setup"))
|
||||
|
||||
std.Out.Write("")
|
||||
overwritePath := filepath.Join(repoRoot, "sg.config.overwrite.yaml")
|
||||
|
||||
@ -56,13 +56,6 @@ Code Insights is currently enabled by default on customer instances 3.32 and lat
|
||||
},
|
||||
```
|
||||
|
||||
## Database
|
||||
Historically, Code Insights used a [TimescaleDB](https://www.timescale.com) database running on the OSS license. The original intention was to use
|
||||
some of the timeseries query features, as well as the hypertable. Many of these are behind a proprietary license that would have required non-trivial
|
||||
work to bundle with Sourcegraph.
|
||||
|
||||
As of Sourcegraph 3.38, Code Insights no longer uses TimescaleDB and has moved to a standard vanilla Postgres image.
|
||||
|
||||
## Insight Metadata
|
||||
Code Insights data is stored entirely in the `codeinsights-db` database, and exposed through a GraphQL API. Settings are deprecated as a storage
|
||||
option, although the text in the settings will persist unless deleted. In this release Code Insights shipped an [out of band migration](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@b098cc6/-/blob/internal/insights/migration/migration.go) that automatically migrates
|
||||
|
||||
@ -33,7 +33,6 @@ Note: that some part of insights logic is stored in `./client/web/src/insights`
|
||||
- `analytics.ts` - analytics logic to get insights setting cascade related metrics (such as code insights count)
|
||||
- `types.ts` - code insights related types for top-level component props.
|
||||
- `utils` - utils functionality such as code insights experimental flags checkers.
|
||||
- `./sections` - OSS version of insights grid components that are rendered at the homepage and the directory page .
|
||||
|
||||
## Insight types
|
||||
|
||||
@ -250,22 +249,6 @@ by few FE network search API requests in case of Built-In insight.
|
||||
> NOTE: We load our insights one by one with a maximum of two insight data requests in parallel to avoid HTTP request bombarding and HTTP 1 limit
|
||||
> with only six requests in parallel. To do that, we use [`useParallelRequests` react hook](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web/src/enterprise/insights/hooks/use-parallel-requests/use-parallel-request.ts)
|
||||
|
||||
### The directory and search (home) pages
|
||||
|
||||

|
||||
|
||||
The directory page is another place where you can find insights (and other extension-based things).
|
||||
This page renders an insight grid component with all insights that you have in your subject settings so that we could say that
|
||||
this is kind of analog of the All insights dashboard on the dashboard page.
|
||||
|
||||
But this page uses a slightly different approach how to load insights data. The directory and search pages render `ExtensionViewsSection`
|
||||
component. This component is different from the OSS to Enterprise version (note, the OSS version is removed as of 5.1). But in both cases, this component is responsible for loading
|
||||
extension and insight-like views and render them into the grid layout views component as it's shown in the picture above.
|
||||
|
||||
- In OSS version (removed in 5.1) it renders only extension views [source](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web/src/insights/sections/ExtensionViewsSection.tsx)
|
||||
- In Enterprise it renders extension and insight like views together. (Code insights is part of enterprise version)
|
||||
[source](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web/src/enterprise/insights/sections/ExtensionViewsSection.tsx)
|
||||
|
||||
## Code Insights loading logic (InsightsApiContext)
|
||||
|
||||
All async operation which is related to fetching data or calling something from the extension API is produced and provided via
|
||||
|
||||
@ -1179,7 +1179,6 @@ Flags:
|
||||
|
||||
* `--check, -c`: Run checks and report setup state
|
||||
* `--fix, -f`: Fix all checks
|
||||
* `--oss`: Omit Sourcegraph-teammate-specific setup
|
||||
* `--skip-pre-commit`: Skip overwriting pre-commit.com installation
|
||||
|
||||
### sg setup disable-pre-commit
|
||||
|
||||
@ -7,7 +7,7 @@ This document describes the TypeScript projects in this repository and how they
|
||||
We use TypeScript for two products:
|
||||
|
||||
- [`web`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/web): The main Sourcegraph web application
|
||||
- 2 different entrypoints: [formerly-OSS `main.tsx`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/web/src/main.tsx) and [Enterprise `main.tsx`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/web/src/enterprise/main.tsx)
|
||||
- Entrypoint: [`main.tsx`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/web/src/enterprise/main.tsx)
|
||||
- [`browser`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/client/brower): The Sourcegraph browser extension
|
||||
|
||||
These both use shared TypeScript code in [`../shared`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/tree/shared). Each product has its own separate esbuild configuration.
|
||||
|
||||
@ -33,12 +33,6 @@ To install it, [see the instructions](../../setup/quickstart.md).
|
||||
sg start # which defaults to `sg start enterprise`
|
||||
```
|
||||
|
||||
For the open-source version:
|
||||
|
||||
```sh
|
||||
sg start oss
|
||||
```
|
||||
|
||||
3. Regenerate GraphQL schema, Typescript types for GraphQL operations and CSS Modules.
|
||||
|
||||
```sh
|
||||
|
||||
@ -57,8 +57,6 @@ You can also try [Sourcegraph.com](https://sourcegraph.com/search), which is a p
|
||||
|
||||
Sourcegraph Enterprise is Sourcegraph’s primary offering and includes all code intelligence platform features. Sourcegraph Enterprise is the best solution for enterprises who want to use Sourcegraph with their organization’s code.
|
||||
|
||||
[Cody](https://docs.sourcegraph.com/cody), Sourcegraph's AI-enabled editor assistant, is free and [open source](https://about.sourcegraph.com/blog/open-sourcing-cody) and is licensed under the Apache 2.0 license.
|
||||
|
||||
Sourcegraph extensions are also OSS licensed (Apache 2), such as:
|
||||
|
||||
- [Sourcegraph browser extension](https://github.com/sourcegraph/sourcegraph/tree/master/client/browser)
|
||||
|
||||
@ -848,8 +848,6 @@ func TestPermissionSyncingDisabled(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// This test lives in cmd/enterprise because it tests a proprietary
|
||||
// super-set of the validation performed by the OSS version.
|
||||
func TestValidateExternalServiceConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Cleanup(licensing.TestingSkipFeatureChecks())
|
||||
|
||||
@ -54,40 +54,16 @@ type AuthzStore interface {
|
||||
GrantPendingPermissions(ctx context.Context, args *GrantPendingPermissionsArgs) error
|
||||
// AuthorizedRepos checks if a user is authorized to access repositories in the candidate list.
|
||||
// The returned list must be a list of repositories that are authorized to the given user.
|
||||
// It is a no-op in the OSS version.
|
||||
AuthorizedRepos(ctx context.Context, args *AuthorizedReposArgs) ([]*types.Repo, error)
|
||||
// RevokeUserPermissions deletes both effective and pending permissions that could be related to a user.
|
||||
// It is a no-op in the OSS version.
|
||||
RevokeUserPermissions(ctx context.Context, args *RevokeUserPermissionsArgs) error
|
||||
// Bulk "RevokeUserPermissions" action.
|
||||
RevokeUserPermissionsList(ctx context.Context, argsList []*RevokeUserPermissionsArgs) error
|
||||
}
|
||||
|
||||
// AuthzWith instantiates and returns a new AuthzStore using the other store
|
||||
// handle. In the OSS version, this is a no-op AuthzStore, but this constructor
|
||||
// is overridden in enterprise versions.
|
||||
var AuthzWith = func(other basestore.ShareableStore) AuthzStore {
|
||||
return &noopAuthzStore{}
|
||||
}
|
||||
|
||||
// noopAuthzStore is a no-op placeholder for the OSS version.
|
||||
type noopAuthzStore struct{}
|
||||
|
||||
func (*noopAuthzStore) GrantPendingPermissions(_ context.Context, _ *GrantPendingPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) AuthorizedRepos(_ context.Context, _ *AuthorizedReposArgs) ([]*types.Repo, error) {
|
||||
return []*types.Repo{}, nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) RevokeUserPermissions(_ context.Context, _ *RevokeUserPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*noopAuthzStore) RevokeUserPermissionsList(_ context.Context, _ []*RevokeUserPermissionsArgs) error {
|
||||
return nil
|
||||
}
|
||||
// handle. This constructor is overridden.
|
||||
var AuthzWith func(other basestore.ShareableStore) AuthzStore
|
||||
|
||||
// NewAuthzStore returns an OSS AuthzStore set with enterprise implementation.
|
||||
func NewAuthzStore(logger log.Logger, db DB, clock func() time.Time) AuthzStore {
|
||||
|
||||
@ -28,17 +28,10 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/version"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
// SkipValidate, if true, will skip validation of service configuration.
|
||||
SkipValidate bool
|
||||
// AfterConfigure, if provided, is run after all services' Configure hooks are called
|
||||
AfterConfigure func()
|
||||
}
|
||||
|
||||
// Main is called from the `main` function of `cmd/sourcegraph`.
|
||||
//
|
||||
// args is the commandline arguments (usually os.Args).
|
||||
func Main(services []sgservice.Service, config Config, args []string) {
|
||||
func Main(services []sgservice.Service, args []string) {
|
||||
// Unlike other sourcegraph binaries we expect to be run
|
||||
// by a user instead of deployed to a cloud. So adjust the default output
|
||||
// format before initializing log.
|
||||
@ -94,7 +87,7 @@ func Main(services []sgservice.Service, config Config, args []string) {
|
||||
logger.Error("cleaning up", log.Error(err))
|
||||
}
|
||||
}()
|
||||
run(liblog, logger, services, config, nil)
|
||||
run(liblog, logger, services, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -111,7 +104,7 @@ func Main(services []sgservice.Service, config Config, args []string) {
|
||||
//
|
||||
// If your service cannot access site configuration, use SingleServiceMainWithoutConf
|
||||
// instead.
|
||||
func SingleServiceMain(svc sgservice.Service, config Config) {
|
||||
func SingleServiceMain(svc sgservice.Service) {
|
||||
liblog := log.Init(log.Resource{
|
||||
Name: env.MyName,
|
||||
Version: version.Version(),
|
||||
@ -125,7 +118,7 @@ func SingleServiceMain(svc sgservice.Service, config Config) {
|
||||
),
|
||||
)
|
||||
logger := log.Scoped("sourcegraph")
|
||||
run(liblog, logger, []sgservice.Service{svc}, config, nil)
|
||||
run(liblog, logger, []sgservice.Service{svc}, nil)
|
||||
}
|
||||
|
||||
// OutOfBandConfiguration declares additional configuration that happens continuously,
|
||||
@ -143,7 +136,7 @@ type OutOfBandConfiguration struct {
|
||||
// service WITHOUT site configuration enabled by default. This is only useful for services
|
||||
// that are not part of the core Sourcegraph deployment, such as executors and managed
|
||||
// services. Use with care!
|
||||
func SingleServiceMainWithoutConf(svc sgservice.Service, config Config, oobConfig OutOfBandConfiguration) {
|
||||
func SingleServiceMainWithoutConf(svc sgservice.Service, oobConfig OutOfBandConfiguration) {
|
||||
liblog := log.Init(log.Resource{
|
||||
Name: env.MyName,
|
||||
Version: version.Version(),
|
||||
@ -157,14 +150,13 @@ func SingleServiceMainWithoutConf(svc sgservice.Service, config Config, oobConfi
|
||||
),
|
||||
)
|
||||
logger := log.Scoped("sourcegraph")
|
||||
run(liblog, logger, []sgservice.Service{svc}, config, &oobConfig)
|
||||
run(liblog, logger, []sgservice.Service{svc}, &oobConfig)
|
||||
}
|
||||
|
||||
func run(
|
||||
liblog *log.PostInitCallbacks,
|
||||
logger log.Logger,
|
||||
services []sgservice.Service,
|
||||
config Config,
|
||||
// If nil, will use site config
|
||||
oobConfig *OutOfBandConfiguration,
|
||||
) {
|
||||
@ -210,24 +202,18 @@ func run(
|
||||
// Validate each service's configuration.
|
||||
//
|
||||
// This cannot be done for executor, see the executorcmd package for details.
|
||||
if !config.SkipValidate {
|
||||
for i, c := range serviceConfigs {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
if err := c.Validate(); err != nil {
|
||||
logger.Fatal("invalid configuration", log.String("service", services[i].Name()), log.Error(err))
|
||||
}
|
||||
for i, c := range serviceConfigs {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
if err := c.Validate(); err != nil {
|
||||
logger.Fatal("invalid configuration", log.String("service", services[i].Name()), log.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
env.Lock()
|
||||
env.HandleHelpFlag()
|
||||
|
||||
if config.AfterConfigure != nil {
|
||||
config.AfterConfigure()
|
||||
}
|
||||
|
||||
// Start the debug server. The ready boolean state it publishes will become true when *all*
|
||||
// services report ready.
|
||||
var allReadyWG sync.WaitGroup
|
||||
|
||||
Loading…
Reference in New Issue
Block a user