sourcegraph/schema/stringdata.go
Felix Kling f8f54f95ab
app: Dedicated local repo external service (#51805)
This commit introduces a dedicated external service (configuration) for
local repositories.

Until now we've piggybacked on OTHER, but that's been more of a
workaround by using a "magic value" in the `repos` field, and restricts
us to the configuration options provided by OTHER.

Having a dedicated external service lets us (more easily)...

- define configuration options useful for local repositories. This
commit allows associating a "group" with a path/pattern to make it
possible for users to resolve repo name conflicts.
- more easily configure the backend to use `file:` URLs to access the
repo. This means we don't need `servegit` anymore to expose git repos on
a local port, simplifying the overall architecture.

---

The implementation was inspired by OTHER and the `servegit` package. It
works as follows:

On startup the `localcodhost` service reads the
`~/.config/sourcegraph-sp/repos.json` config file to create a local
external service configuration (`LocalExternalService`). The structure
of the configuration file is something like

```
{ 
  "repos": [
    {"pattern": "glob/pattern/*", "group": "<group-name>"}
  ]
}
```

where `<group-name>` is optional and can be used to namespace
repositories from different directories.
I'm reusing the service ID that had been used for autogenerated repo
syncing via servegit.

This configuration is eventually passed to `LocalSource`, which resolves
the glob patterns when listing the available repositories.

As can be seen in `clone_url.go` we simply create `file:///` URLs for
LOCAL repositories, which avoids needing to run another HTTP service to
access the files.

---

Notes:

- This is a first step. I expect that we'll extend the configuration as
needed but we should strive to keep it as simple as possible.
- Eventually the service should re-read the configuration from disk.
- We have to decide whether configuring local repos from the setup
wizard will update the config file or simply create separate
configurations (either should be fine).
- I haven't removed the `servegit` service just yet so that the existing
app setup experience will continue to work.
- Any good ideas for testing this, especially the file system
interaction?


## Test plan

- Create the `repos` file in the apps config directory.
- When the sourcegraph app is started from the terminal, the terminal
output will list which repos have been found.
- Local repositories are visible in the repositories tab.
2023-06-07 15:14:36 +02:00

107 lines
2.9 KiB
Go

package schema
import _ "embed"
// AWSCodeCommitSchemaJSON is the content of the file "aws_codecommit.schema.json".
//
//go:embed aws_codecommit.schema.json
var AWSCodeCommitSchemaJSON string
// AzureDevOpsSchemaJSON is the content of the file "azuredevops.schema.json".
//
//go:embed azuredevops.schema.json
var AzureDevOpsSchemaJSON string
// BatchSpecSchemaJSON is the content of the file "batch_spec.schema.json".
//
//go:embed batch_spec.schema.json
var BatchSpecSchemaJSON string
// BitbucketCloudSchemaJSON is the content of the file "bitbucket_cloud.schema.json".
//
//go:embed bitbucket_cloud.schema.json
var BitbucketCloudSchemaJSON string
// BitbucketServerSchemaJSON is the content of the file "bitbucket_server.schema.json".
//
//go:embed bitbucket_server.schema.json
var BitbucketServerSchemaJSON string
// ChangesetSpecSchemaJSON is the content of the file "changeset_spec.schema.json".
//
//go:embed changeset_spec.schema.json
var ChangesetSpecSchemaJSON string
// GerritSchemaJSON is the content of the file "gerrit.schema.json".
//
//go:embed gerrit.schema.json
var GerritSchemaJSON string
// GitHubSchemaJSON is the content of the file "github.schema.json".
//
//go:embed github.schema.json
var GitHubSchemaJSON string
// GitLabSchemaJSON is the content of the file "gitlab.schema.json".
//
//go:embed gitlab.schema.json
var GitLabSchemaJSON string
// GitoliteSchemaJSON is the content of the file "gitolite.schema.json".
//
//go:embed gitolite.schema.json
var GitoliteSchemaJSON string
//go:embed go-modules.schema.json
var GoModulesSchemaJSON string
//go:embed jvm-packages.schema.json
var JVMPackagesSchemaJSON string
//go:embed npm-packages.schema.json
var NpmPackagesSchemaJSON string
//go:embed python-packages.schema.json
var PythonPackagesSchemaJSON string
//go:embed rust-packages.schema.json
var RustPackagesSchemaJSON string
//go:embed ruby-packages.schema.json
var RubyPackagesSchemaJSON string
// OtherExternalServiceSchemaJSON is the content of the file "other_external_service.schema.json".
//
//go:embed other_external_service.schema.json
var OtherExternalServiceSchemaJSON string
// LocalGitExternalServiceSchemaJSON is the content of the file "localgit.schema.json".
//
//go:embed localgit.schema.json
var LocalGitExternalServiceSchemaJSON string
// PerforceSchemaJSON is the content of the file "perforce.schema.json".
//
//go:embed perforce.schema.json
var PerforceSchemaJSON string
// PhabricatorSchemaJSON is the content of the file "phabricator.schema.json".
//
//go:embed phabricator.schema.json
var PhabricatorSchemaJSON string
// PagureSchemaJSON is the content of the file "pagure.schema.json".
//
//go:embed pagure.schema.json
var PagureSchemaJSON string
// SettingsSchemaJSON is the content of the file "settings.schema.json".
//
//go:embed settings.schema.json
var SettingsSchemaJSON string
// SiteSchemaJSON is the content of the file "site.schema.json".
//
//go:embed site.schema.json
var SiteSchemaJSON string