From e5baad0ccd7e24e5708f8c0edd92228422dbfb11 Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Thu, 9 Nov 2023 21:59:03 -1000 Subject: [PATCH] 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 --- .eslintrc.js | 6 --- README.md | 5 +-- client/web-sveltekit/BUILD.bazel | 3 +- client/web-sveltekit/README.md | 5 +-- client/web-sveltekit/package.json | 1 - client/web/scripts/report-bundle-diff.ts | 4 +- client/web/src/batches/backend.ts | 5 --- client/web/src/codeintel/BrainDot.tsx | 3 +- client/web/src/insights/types.ts | 2 - client/web/src/nav/GlobalNavbar.tsx | 12 ++++- .../search/results/StreamingSearchResults.tsx | 2 - client/web/src/storm/routes.tsx | 2 +- cmd/blobstore/BUILD.bazel | 2 +- cmd/blobstore/main.go | 4 +- cmd/cody-gateway/main.go | 2 +- cmd/embeddings/main.go | 4 +- cmd/frontend/backend/BUILD.bazel | 1 + cmd/frontend/backend/user_emails_test.go | 40 +++++++++++++++++ .../graphqlbackend/product_license_info.go | 7 +-- cmd/frontend/main.go | 2 +- cmd/gitserver/BUILD.bazel | 2 +- cmd/gitserver/main.go | 4 +- cmd/pings/main.go | 2 +- cmd/precise-code-intel-worker/main.go | 4 +- cmd/repo-updater/BUILD.bazel | 2 +- cmd/repo-updater/main.go | 4 +- cmd/searcher/BUILD.bazel | 2 +- cmd/searcher/main.go | 4 +- cmd/sourcegraph/BUILD.bazel | 2 +- cmd/sourcegraph/main.go | 4 +- cmd/sourcegraph/osscmd/BUILD.bazel | 13 ------ cmd/sourcegraph/osscmd/osscmd.go | 28 ------------ cmd/symbols/main.go | 4 +- cmd/telemetry-gateway/main.go | 2 +- cmd/worker/BUILD.bazel | 2 +- cmd/worker/main.go | 4 +- dev/check/all.sh | 2 - dev/check/go-enterprise-import.sh | 22 --------- dev/check/ts-enterprise-import.sh | 35 --------------- dev/depgraph/README.md | 1 - dev/depgraph/internal/lints/BUILD.bazel | 1 - dev/depgraph/internal/lints/lint.go | 1 - .../lints/no_enterprise_imports_from_oss.go | 45 ------------------- dev/sg/dependencies/dependencies.go | 2 - dev/sg/dependencies/dependencies_test.go | 1 - dev/sg/dependencies/helpers.go | 9 ---- dev/sg/dependencies/mac.go | 1 - dev/sg/dependencies/shared.go | 21 +++------ dev/sg/dependencies/ubuntu.go | 1 - dev/sg/internal/sgconf/config_test.go | 10 ++--- dev/sg/linters/BUILD.bazel | 1 - dev/sg/linters/enterprise.go | 6 --- dev/sg/linters/linters.go | 2 - dev/sg/sg.config.example.yaml | 11 ----- dev/sg/sg_setup.go | 14 ------ dev/sg/sg_start.go | 5 +-- .../insights/backend.md | 7 --- .../insights/frontend.md | 17 ------- .../background-information/sg/reference.md | 1 - doc/dev/background-information/web/build.md | 2 +- doc/dev/background-information/web/web_app.md | 6 --- doc/getting-started/index.md | 2 - internal/authz/providers/authz_test.go | 2 - internal/database/authz.go | 28 +----------- internal/service/svcmain/svcmain.go | 38 +++++----------- 65 files changed, 112 insertions(+), 377 deletions(-) delete mode 100644 cmd/sourcegraph/osscmd/BUILD.bazel delete mode 100644 cmd/sourcegraph/osscmd/osscmd.go delete mode 100755 dev/check/go-enterprise-import.sh delete mode 100755 dev/check/ts-enterprise-import.sh delete mode 100644 dev/depgraph/internal/lints/no_enterprise_imports_from_oss.go delete mode 100644 dev/sg/linters/enterprise.go diff --git a/.eslintrc.js b/.eslintrc.js index 518ada1993a..9bd5e4cdc48 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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: diff --git a/README.md b/README.md index 742f0e70632..5f1e08f27f0 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/client/web-sveltekit/BUILD.bazel b/client/web-sveltekit/BUILD.bazel index bfad63787cb..2a6234f908f 100644 --- a/client/web-sveltekit/BUILD.bazel +++ b/client/web-sveltekit/BUILD.bazel @@ -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, ) diff --git a/client/web-sveltekit/README.md b/client/web-sveltekit/README.md index 8c5707dd599..4cd161e2509 100644 --- a/client/web-sveltekit/README.md +++ b/client/web-sveltekit/README.md @@ -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, diff --git a/client/web-sveltekit/package.json b/client/web-sveltekit/package.json index 4a1f49e5020..c147f69ceff 100644 --- a/client/web-sveltekit/package.json +++ b/client/web-sveltekit/package.json @@ -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", diff --git a/client/web/scripts/report-bundle-diff.ts b/client/web/scripts/report-bundle-diff.ts index a747059cd28..9862a7e3e03 100644 --- a/client/web/scripts/report-bundle-diff.ts +++ b/client/web/scripts/report-bundle-diff.ts @@ -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 { - // 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) diff --git a/client/web/src/batches/backend.ts b/client/web/src/batches/backend.ts index 61e0b99dd6a..610bec38298 100644 --- a/client/web/src/batches/backend.ts +++ b/client/web/src/batches/backend.ts @@ -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) { diff --git a/client/web/src/codeintel/BrainDot.tsx b/client/web/src/codeintel/BrainDot.tsx index f57faf782ce..3a395fe3e8b 100644 --- a/client/web/src/codeintel/BrainDot.tsx +++ b/client/web/src/codeintel/BrainDot.tsx @@ -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 = () => null diff --git a/client/web/src/insights/types.ts b/client/web/src/insights/types.ts index db47d6a0565..5b5e56f5202 100644 --- a/client/web/src/insights/types.ts +++ b/client/web/src/insights/types.ts @@ -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 diff --git a/client/web/src/nav/GlobalNavbar.tsx b/client/web/src/nav/GlobalNavbar.tsx index 09ac58b8078..c733a5a67d6 100644 --- a/client/web/src/nav/GlobalNavbar.tsx +++ b/client/web/src/nav/GlobalNavbar.tsx @@ -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 = 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(() => { diff --git a/client/web/src/storm/routes.tsx b/client/web/src/storm/routes.tsx index d4bf3e01fdf..e8d322152ff 100644 --- a/client/web/src/storm/routes.tsx +++ b/client/web/src/storm/routes.tsx @@ -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. * diff --git a/cmd/blobstore/BUILD.bazel b/cmd/blobstore/BUILD.bazel index c54e7a10f39..9435ef3642d 100644 --- a/cmd/blobstore/BUILD.bazel +++ b/cmd/blobstore/BUILD.bazel @@ -10,8 +10,8 @@ go_library( visibility = ["//visibility:private"], deps = [ "//cmd/blobstore/shared", - "//cmd/sourcegraph/osscmd", "//internal/sanitycheck", + "//internal/service/svcmain", ], ) diff --git a/cmd/blobstore/main.go b/cmd/blobstore/main.go index 241563b753a..9f83bee5b43 100644 --- a/cmd/blobstore/main.go +++ b/cmd/blobstore/main.go @@ -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) } diff --git a/cmd/cody-gateway/main.go b/cmd/cody-gateway/main.go index 25743403adf..e83ada24055 100644 --- a/cmd/cody-gateway/main.go +++ b/cmd/cody-gateway/main.go @@ -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 diff --git a/cmd/embeddings/main.go b/cmd/embeddings/main.go index dbb74f99afb..487228576d6 100644 --- a/cmd/embeddings/main.go +++ b/cmd/embeddings/main.go @@ -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) } diff --git a/cmd/frontend/backend/BUILD.bazel b/cmd/frontend/backend/BUILD.bazel index 7ab3c2a9e40..058f009cecd 100644 --- a/cmd/frontend/backend/BUILD.bazel +++ b/cmd/frontend/backend/BUILD.bazel @@ -91,6 +91,7 @@ go_test( "//internal/api", "//internal/conf", "//internal/database", + "//internal/database/basestore", "//internal/database/dbmocks", "//internal/database/dbtest", "//internal/encryption", diff --git a/cmd/frontend/backend/user_emails_test.go b/cmd/frontend/backend/user_emails_test.go index 03f6cb31cf0..e8bfc8464f5 100644 --- a/cmd/frontend/backend/user_emails_test.go +++ b/cmd/frontend/backend/user_emails_test.go @@ -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() diff --git a/cmd/frontend/graphqlbackend/product_license_info.go b/cmd/frontend/graphqlbackend/product_license_info.go index f0b0982ebc5..163bc066c02 100644 --- a/cmd/frontend/graphqlbackend/product_license_info.go +++ b/cmd/frontend/graphqlbackend/product_license_info.go @@ -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 diff --git a/cmd/frontend/main.go b/cmd/frontend/main.go index 1383c11094a..a744d44d7cd 100644 --- a/cmd/frontend/main.go +++ b/cmd/frontend/main.go @@ -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()), diff --git a/cmd/gitserver/BUILD.bazel b/cmd/gitserver/BUILD.bazel index 4cac7c4d86f..9af834d2e45 100644 --- a/cmd/gitserver/BUILD.bazel +++ b/cmd/gitserver/BUILD.bazel @@ -11,8 +11,8 @@ go_library( visibility = ["//visibility:private"], deps = [ "//cmd/gitserver/shared", - "//cmd/sourcegraph/osscmd", "//internal/sanitycheck", + "//internal/service/svcmain", ], ) diff --git a/cmd/gitserver/main.go b/cmd/gitserver/main.go index 80ac02ad17b..29ddaf82b5f 100644 --- a/cmd/gitserver/main.go +++ b/cmd/gitserver/main.go @@ -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) } diff --git a/cmd/pings/main.go b/cmd/pings/main.go index 2ce89ec2c65..2966ae4b446 100644 --- a/cmd/pings/main.go +++ b/cmd/pings/main.go @@ -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 diff --git a/cmd/precise-code-intel-worker/main.go b/cmd/precise-code-intel-worker/main.go index 1ebcdbd1278..f1e54618ac4 100644 --- a/cmd/precise-code-intel-worker/main.go +++ b/cmd/precise-code-intel-worker/main.go @@ -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) } diff --git a/cmd/repo-updater/BUILD.bazel b/cmd/repo-updater/BUILD.bazel index 9df765d4d49..a1de2643ef2 100644 --- a/cmd/repo-updater/BUILD.bazel +++ b/cmd/repo-updater/BUILD.bazel @@ -11,8 +11,8 @@ go_library( visibility = ["//visibility:private"], deps = [ "//cmd/repo-updater/shared", - "//cmd/sourcegraph/osscmd", "//internal/sanitycheck", + "//internal/service/svcmain", ], ) diff --git a/cmd/repo-updater/main.go b/cmd/repo-updater/main.go index 2867850801e..3c0ac54b83c 100644 --- a/cmd/repo-updater/main.go +++ b/cmd/repo-updater/main.go @@ -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) } diff --git a/cmd/searcher/BUILD.bazel b/cmd/searcher/BUILD.bazel index c8319e008b5..84f940f03c2 100644 --- a/cmd/searcher/BUILD.bazel +++ b/cmd/searcher/BUILD.bazel @@ -11,8 +11,8 @@ go_library( visibility = ["//visibility:private"], deps = [ "//cmd/searcher/shared", - "//cmd/sourcegraph/osscmd", "//internal/sanitycheck", + "//internal/service/svcmain", ], ) diff --git a/cmd/searcher/main.go b/cmd/searcher/main.go index 92bce40e9eb..c74098632c2 100644 --- a/cmd/searcher/main.go +++ b/cmd/searcher/main.go @@ -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) } diff --git a/cmd/sourcegraph/BUILD.bazel b/cmd/sourcegraph/BUILD.bazel index 56283e96cdb..95b294dbd33 100644 --- a/cmd/sourcegraph/BUILD.bazel +++ b/cmd/sourcegraph/BUILD.bazel @@ -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", ], ) diff --git a/cmd/sourcegraph/main.go b/cmd/sourcegraph/main.go index 378f1366dcb..fbb27f5d888 100644 --- a/cmd/sourcegraph/main.go +++ b/cmd/sourcegraph/main.go @@ -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) } diff --git a/cmd/sourcegraph/osscmd/BUILD.bazel b/cmd/sourcegraph/osscmd/BUILD.bazel deleted file mode 100644 index c4f2eb10cb4..00000000000 --- a/cmd/sourcegraph/osscmd/BUILD.bazel +++ /dev/null @@ -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", - ], -) diff --git a/cmd/sourcegraph/osscmd/osscmd.go b/cmd/sourcegraph/osscmd/osscmd.go deleted file mode 100644 index e459055cdf9..00000000000 --- a/cmd/sourcegraph/osscmd/osscmd.go +++ /dev/null @@ -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) -} diff --git a/cmd/symbols/main.go b/cmd/symbols/main.go index 4f353703dfa..5e668ec588b 100644 --- a/cmd/symbols/main.go +++ b/cmd/symbols/main.go @@ -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) } diff --git a/cmd/telemetry-gateway/main.go b/cmd/telemetry-gateway/main.go index ca401858834..a8d1648c034 100644 --- a/cmd/telemetry-gateway/main.go +++ b/cmd/telemetry-gateway/main.go @@ -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 diff --git a/cmd/worker/BUILD.bazel b/cmd/worker/BUILD.bazel index 315ade4a93c..ed73e3e183a 100644 --- a/cmd/worker/BUILD.bazel +++ b/cmd/worker/BUILD.bazel @@ -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", ], ) diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 24f8095b1c4..9d5f7833bff 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -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) } diff --git a/dev/check/all.sh b/dev/check/all.sh index bbb9846685b..11367a2823b 100755 --- a/dev/check/all.sh +++ b/dev/check/all.sh @@ -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 ) diff --git a/dev/check/go-enterprise-import.sh b/dev/check/go-enterprise-import.sh deleted file mode 100755 index 0deb99b52f8..00000000000 --- a/dev/check/go-enterprise-import.sh +++ /dev/null @@ -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 diff --git a/dev/check/ts-enterprise-import.sh b/dev/check/ts-enterprise-import.sh deleted file mode 100755 index c9987ef9d49..00000000000 --- a/dev/check/ts-enterprise-import.sh +++ /dev/null @@ -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 < 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 - -![directory-page.png](https://storage.googleapis.com/sourcegraph-assets/code_insights/directory-page.png) - -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 diff --git a/doc/dev/background-information/sg/reference.md b/doc/dev/background-information/sg/reference.md index 6f07c06edcb..014639648c2 100644 --- a/doc/dev/background-information/sg/reference.md +++ b/doc/dev/background-information/sg/reference.md @@ -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 diff --git a/doc/dev/background-information/web/build.md b/doc/dev/background-information/web/build.md index 14bfba9939a..cf8fd2c51b5 100644 --- a/doc/dev/background-information/web/build.md +++ b/doc/dev/background-information/web/build.md @@ -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. diff --git a/doc/dev/background-information/web/web_app.md b/doc/dev/background-information/web/web_app.md index 9d332424626..e8df68461c1 100644 --- a/doc/dev/background-information/web/web_app.md +++ b/doc/dev/background-information/web/web_app.md @@ -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 diff --git a/doc/getting-started/index.md b/doc/getting-started/index.md index 8c0e7c29119..09b5275d232 100644 --- a/doc/getting-started/index.md +++ b/doc/getting-started/index.md @@ -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) diff --git a/internal/authz/providers/authz_test.go b/internal/authz/providers/authz_test.go index 926c54e55e5..af0cae4acd4 100644 --- a/internal/authz/providers/authz_test.go +++ b/internal/authz/providers/authz_test.go @@ -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()) diff --git a/internal/database/authz.go b/internal/database/authz.go index e23c7e46d9e..b193deee024 100644 --- a/internal/database/authz.go +++ b/internal/database/authz.go @@ -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 { diff --git a/internal/service/svcmain/svcmain.go b/internal/service/svcmain/svcmain.go index f37045fc812..5308b5ab51c 100644 --- a/internal/service/svcmain/svcmain.go +++ b/internal/service/svcmain/svcmain.go @@ -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