sourcegraph/schema/bitbucket_cloud.schema.json
Erik Seliger 20ef9619cc
Add support for naming repo explicitly for Bitbucket Cloud (#61536)
This aligns the configuration for Bitbucket Cloud with most other code hosts where we allow to name repos explicitly. This makes it easier to test the connection for a single repo first, instead of having to sync potentially thousands of repos right away.

## Test plan

Added a test using real-world data with VCR and verified manually on my local instance that I can successfully sync single repos.
2024-04-08 19:03:53 +02:00

164 lines
7.7 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "bitbucket_cloud.schema.json#",
"title": "BitbucketCloudConnection",
"description": "Configuration for a connection to Bitbucket Cloud.",
"allowComments": true,
"type": "object",
"additionalProperties": false,
"required": ["url"],
"oneOf": [
{
"allOf": [
{
"required": ["accessToken"]
},
{
"not": { "required": ["username"] }
},
{
"not": { "required": ["appPassword"] }
}
]
},
{
"required": ["username", "appPassword"],
"not": { "required": ["accessToken"] }
}
],
"properties": {
"url": {
"description": "URL of Bitbucket Cloud, such as https://bitbucket.org. Generally, admin should not modify the value of this option because Bitbucket Cloud is a public hosting platform.",
"type": "string",
"not": {
"type": "string",
"pattern": "example\\.com"
},
"pattern": "^https?://",
"format": "uri",
"examples": ["https://bitbucket.org"]
},
"apiURL": {
"description": "The API URL of Bitbucket Cloud, such as https://api.bitbucket.org. Generally, admin should not modify the value of this option because Bitbucket Cloud is a public hosting platform.",
"type": "string",
"not": {
"type": "string",
"pattern": "example\\.com"
},
"pattern": "^https?://",
"format": "uri",
"examples": ["https://api.bitbucket.org"]
},
"rateLimit": {
"description": "Rate limit applied when making background API requests to Bitbucket Cloud.",
"title": "BitbucketCloudRateLimit",
"type": "object",
"required": ["enabled", "requestsPerHour"],
"properties": {
"enabled": {
"description": "true if rate limiting is enabled.",
"type": "boolean",
"default": true
},
"requestsPerHour": {
"description": "Requests per hour permitted. This is an average, calculated per second. Internally, the burst limit is set to 500, which implies that for a requests per hour limit as low as 1, users will continue to be able to send a maximum of 500 requests immediately, provided that the complexity cost of each request is 1.",
"type": "number",
"default": 7200,
"minimum": 0
}
},
"default": {
"enabled": true,
"requestsPerHour": 7200
}
},
"authorization": {
"title": "BitbucketCloudAuthorization",
"description": "If non-null, enforces Bitbucket Cloud 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 \"bitbucketcloud\" with the same `url` field as specified in this `BitbucketCloudConnection`.",
"type": "object",
"properties": {
"identityProvider": {
"description": "The identity provider to use for user information. If not set, the `url` field is used.",
"type": "string"
}
}
},
"username": {
"description": "The username to use when authenticating to the Bitbucket Cloud. Also set the corresponding \"appPassword\" field.",
"type": "string"
},
"appPassword": {
"description": "The app password to use when authenticating to the Bitbucket Cloud. Also set the corresponding \"username\" field.",
"type": "string"
},
"accessToken": {
"description": "The workspace access token to use when authenticating with Bitbucket Cloud.",
"type": "string"
},
"gitURLType": {
"description": "The type of Git URLs to use for cloning and fetching Git repositories on this Bitbucket Cloud.\n\nIf \"http\", Sourcegraph will access Bitbucket Cloud repositories using Git URLs of the form https://bitbucket.org/myteam/myproject.git.\n\nIf \"ssh\", Sourcegraph will access Bitbucket Cloud repositories using Git URLs of the form git@bitbucket.org:myteam/myproject.git. See the documentation for how to provide SSH private keys and known_hosts: https://sourcegraph.com/docs/admin/repo/auth#repositories-that-need-http-s-or-ssh-authentication.",
"type": "string",
"enum": ["http", "ssh"],
"default": "http",
"examples": ["ssh"]
},
"repositoryPathPattern": {
"description": "The pattern used to generate the corresponding Sourcegraph repository name for a Bitbucket Cloud repository.\n\n - \"{host}\" is replaced with the Bitbucket Cloud URL's host (such as bitbucket.org), and \"{nameWithOwner}\" is replaced with the Bitbucket Cloud repository's \"owner/path\" (such as \"myorg/myrepo\").\n\nFor example, if your Bitbucket Cloud is https://bitbucket.org and your Sourcegraph is https://src.example.com, then a repositoryPathPattern of \"{host}/{nameWithOwner}\" would mean that a Bitbucket Cloud repository at https://bitbucket.org/alice/my-repo is available on Sourcegraph at https://src.example.com/bitbucket.org/alice/my-repo.\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}/{nameWithOwner}"
},
"teams": {
"description": "An array of team names identifying Bitbucket Cloud teams whose repositories should be mirrored on Sourcegraph.",
"type": "array",
"items": { "type": "string", "pattern": "^[\\w-]+$" },
"examples": [["name"], ["kubernetes", "golang", "facebook"]]
},
"repos": {
"description": "An array of repository \"projectKey/repositorySlug\" strings specifying repositories to mirror on Sourcegraph.",
"type": "array",
"items": {
"type": "string",
"pattern": "^~?[\\w-]+/[\\w.-]+$"
},
"examples": [["myproject/myrepo", "myproject/myotherrepo"]]
},
"exclude": {
"description": "A list of repositories to never mirror from Bitbucket Cloud. Takes precedence over \"teams\" configuration.\n\nSupports excluding by name ({\"name\": \"myorg/myrepo\"}) or by UUID ({\"uuid\": \"{fceb73c7-cef6-4abe-956d-e471281126bd}\"}).",
"type": "array",
"items": {
"type": "object",
"title": "ExcludedBitbucketCloudRepo",
"additionalProperties": false,
"anyOf": [{ "required": ["name"] }, { "required": ["uuid"] }, { "required": ["pattern"] }],
"properties": {
"name": {
"description": "The name of a Bitbucket Cloud repo (\"myorg/myrepo\") to exclude from mirroring.",
"type": "string",
"pattern": "^[\\w-]+/[\\w.-]+$"
},
"uuid": {
"description": "The UUID of a Bitbucket Cloud repo (as returned by the Bitbucket Cloud's API) to exclude from mirroring.",
"type": "string",
"pattern": "^\\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\}$"
},
"pattern": {
"description": "Regular expression which matches against the name of a Bitbucket Cloud repo.",
"type": "string",
"format": "regex"
}
}
},
"examples": [
[{ "name": "myorg/myrepo" }, { "uuid": "{fceb73c7-cef6-4abe-956d-e471281126bc}" }],
[{ "name": "myorg/myrepo" }, { "name": "myorg/myotherrepo" }, { "pattern": "^topsecretproject/.*" }]
]
},
"webhookSecret": {
"description": "A shared secret used to authenticate incoming webhooks (minimum 12 characters).",
"deprecationMessage": "Deprecated in favour of first class webhooks. See https://sourcegraph.com/docs/admin/config/webhooks/incoming#deprecation-notice",
"type": "string",
"minLength": 12
}
}
}