sourcegraph/schema/gerrit.schema.json
Erik Seliger d249b8f701
gerrit: Add support for repositoryPathPattern (#64102)
Most other code host connections we support have this property to
control the generated name, but for some reason it was forgotten for
Gerrit.

This PR adds it, plus a few tests.

![Screenshot 2024-07-26 at
14.04.35@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Xvbrpl1hwVbe4tb9QeLp/6b7f2e35-1147-4e6d-912c-628ea94f2f33.png)

Test plan: Added tests, cloned a gerrit repo locally.

## Changelog 

Added support for the `repositoryPathPattern` setting for Gerrit code
host connections.
2024-07-26 15:08:14 +02:00

83 lines
4.2 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" }]]
},
"repositoryPathPattern": {
"description": "The pattern used to generate the corresponding Sourcegraph repository name for a Gerrit repository. In the pattern, the variable \"{host}\" is replaced with the Gerrit host (such as gerrit.example.com), and \"{name}\" is replaced with the Gerrit repository's name (such as \"myrepo\").\n\nFor example, if your Gerrit URL is https://gerrit.example.com and your Sourcegraph URL is https://src.example.com, then a repositoryPathPattern of \"{host}/{name}\" would mean that a Gerrit repository at https://gerrit.example.com/myrepo is available on Sourcegraph at https://src.example.com/gerrit.example.com/myrepo.\n\nIt is important that the Sourcegraph repository name generated with this pattern be unique to this code host. If different code hosts generate repository names that collide, Sourcegraph's behavior is undefined.",
"type": "string",
"default": "{host}/{name}"
},
"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"
}
}
}
}
}