mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:51:43 +00:00
To bring Gerrit support more in line with other code hosts and because a customer recently ran into this limitation, this PR adds support for the SSH flag. The diff is mostly straightforward, with two things to watch out for: - The clone URL construction in makeRepo was wrong previously, it missed the `/a/`. This is only used for visuals, but still annoying. So I moved the whole construction into here from the gitserver cloneURL package. - The SSH hostname and port are configurable in Gerrit, so to construct the right URL we need to fetch some instance metadata. This would be costly to do in the gitserver method, so we persist all the info needed to construct clone URLs "offline" during the cloning process by storing all the data for HTTP and SSH clones on the repo metadata column. This is mostly in line with other code hosts as well, see GitLab right above in the gitserver/cloneurl package. Closes https://github.com/sourcegraph/sourcegraph/issues/60597 ## Test plan Added tests for the various stages, recreated recorded responses, and tried both HTTP and SSH cloning locally, both worked with out Gerrit instance.
78 lines
3.3 KiB
JSON
78 lines
3.3 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"$id": "gerrit.schema.json#",
|
|
"title": "GerritConnection",
|
|
"description": "Configuration for a connection to Gerrit.",
|
|
"allowComments": true,
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["url", "username", "password"],
|
|
"properties": {
|
|
"url": {
|
|
"description": "URL of a Gerrit instance, such as https://gerrit.example.com.",
|
|
"type": "string",
|
|
"pattern": "^https?://",
|
|
"not": {
|
|
"type": "string",
|
|
"pattern": "example\\.com"
|
|
},
|
|
"format": "uri",
|
|
"examples": ["https://gerrit.example.com"]
|
|
},
|
|
"username": {
|
|
"description": "A username for authentication with the Gerrit code host.",
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"password": {
|
|
"description": "The password associated with the Gerrit username used for authentication.",
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"projects": {
|
|
"description": "An array of project strings specifying which Gerrit projects to mirror on Sourcegraph. If empty, all projects will be mirrored.",
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"examples": [
|
|
["name", "owner/name"],
|
|
["docs", "kubernetes/kubernetes", "golang/go", "facebook/react"]
|
|
]
|
|
},
|
|
"gitURLType": {
|
|
"description": "The type of Git URLs to use for cloning and fetching Git repositories on this Gerrit instance.\n\nIf \"http\", Sourcegraph will access Gerrit repositories using Git URLs of the form http(s)://gerrit.example.com/a/myteam/myproject.git (using https: if the Gerrit instance uses HTTPS).\n\nIf \"ssh\", Sourcegraph will access Gerrit repositories using Git URLs of the form git@gerrit.example.com:myteam/myproject.git. The exact hostname and port will be fetched from /ssh_info. See the documentation for how to provide SSH private keys and known_hosts: https://sourcegraph.com/docs/admin/repo/auth.",
|
|
"type": "string",
|
|
"enum": ["http", "ssh"],
|
|
"default": "http"
|
|
},
|
|
"exclude": {
|
|
"description": "A list of repositories to never mirror from this Gerrit instance. Takes precedence over \"projects\" configuration.\n\nSupports excluding by name ({\"name\": \"owner/name\"})",
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {
|
|
"type": "object",
|
|
"title": "ExcludedGerritProject",
|
|
"additionalProperties": false,
|
|
"anyOf": [{ "required": ["name"] }],
|
|
"properties": {
|
|
"name": {
|
|
"description": "The name of a Gerrit project to exclude from mirroring.",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"examples": [[{ "name": "docs" }, { "name": "php/php-src" }]]
|
|
},
|
|
"authorization": {
|
|
"title": "GerritAuthorization",
|
|
"description": "If non-null, enforces Gerrit repository permissions. This requires that there is an item in the [site configuration json](https://sourcegraph.com/docs/admin/config/site_config#auth-providers) `auth.providers` field, of type \"gerrit\" with the same `url` field as specified in this `GerritConnection`.",
|
|
"type": "object",
|
|
"properties": {
|
|
"identityProvider": {
|
|
"description": "The identity provider to use for user information. If not set, the `url` field is used.",
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|