This patch enables support for publishing the workspace content to new
project in Gerrit.
This can be broken down to three things:
* "resolveUrl" for the Gerrit integration have been updated to handle
absolute paths correctly.
* "RepoUrlPicker" has been updated to handle gerrit hosts.
* A new scaffolder action has been added that will publish the workspace
content to a newly created Gerrit project.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
"readTree" has been implemented for the "GerritUrlReader". Gerrit have
a REST API's to download repo contents but there are a number of
limitations that makes it unusable.
This implementation works as follows:
* The project and branch is parsed from the url.
* The current revision is fetched from the Gerrit REST API.
* The revision string is used as "etag".
* If the etag has changed a temporary directory is created.
* The project is cloned to the temporary directory.
* The cloned content is read into a "Readable Stream".
* The temporary directory is removed.
* "readTree" returns a response using "fromTarArchive" as read from the
temporary directory.
Also added an option to specify the base "cloneUrl" has been added to the
gerrit integration config.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
The "plugin-catalog-backend-module-gerrit" exports an entity
provider for discovering catalog entities from Gerrit
repositories. The provider uses the "List Projects" API in Gerrit
to get a list of repositories and will automatically ingest all
"catalog-info.yaml" files stored in the root of the matching
projects.
Also added the "getGerritProjectsApiUrl" function to the Gerrit
integration. This returns the url to the "List Projects" API for
a given integration.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
Split `integrations.bitbucket` into `integrations.bitbucketCloud`
and `integrations.bitbucketServer`
while staying backwards compatible for now
(== `BitbucketIntegration` loads from the new configs, too, if the old is not used).
Relates-to: #9923
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
The url used by "readUrl" is supposed to be human friendly url that can
be opened in the browser. This makes the Gerrit configuration a bit more
complicated since there is no built in support to browse a git in Gerrit.
Instead this is handled by separate services that can be deployed at a
different host then the Gerrit instance. This implementation supports
Gitiles as the code browser tool. The dependency to Gitiles is optional,
it is perfectly possible to integrate Gerrit with Backstage but it will
not be possible to open the "human readable links" found in different
places of the Backstage gui.
A new optional config field has been added to Gerrit integration where
the base url of the Gitiles installation can be set. This is needed to
create a working link to some git content.
A new "url reader" has been added that reads content from Gerrit, as of
now only "readUrl" is implemented ("readTree" will soon follow). The
format of url is the format used by Gitiles. Gerrit's "readUrl" is
pretty simple, it's a single API call to Gerrit that returns the content
base64 encoded.
What is a bit different to other "urlReaders" is the predicate
function in that is not matching the host of the Gerrrit API. The "host"
variable in the config is the Gerrit host. The address where Gitiles is
installed may be on the same host but it could be on a separate host.
For example a Gerrit instance could be hosted on
"gerrit-review.company.com" but the repos could be browsable on a
separate host, e.g. "gerrit.company.com" and the human readable URL would
then not point to the API host.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
* Rename "apiBaseUrl" to the more suitable "baseUrl".
* Removed the Gerrit location doc (will be added later together
with the "urlReader" implementation.
* Fixed the line number handling in Gerrit/resolveUrl.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
If the apiBaseUrl is not set assume that the gerrit instance
uses https and can be reached on the address specified by the
"host" option.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
A new ScmIntegration has been added for reading entities from
gits hosted by Gerrit. The UrlReader implementation will be done
in an upcoming patch.
The Gerrit configuration supports the following values:
* host (required) : The host of the gerrit instance to use.
* apiBaseUrl (required): The base url of the gerrit api.
* username (optional): The username to use during authentication.
* password (optional): The password or http token to use for
authentication.
Signed-off-by: Niklas Aronsson <niklasar@axis.com>
Ensure presence of apiBaseUrl for bitbucket
integrations for both cases Bitbucket Cloud and
Bitbucket Server by setting the default for
Bitbucket Server at the integration config, too.
Replace hardcoded uses of the default apiBaseUrl
with the use of the integration config's value.
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
Use the actual line number syntax for Bitbucket Cloud
and Bitbucket Server.
Closes: #9764
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
Changed the repoIDLookup concatenation from 'url.protocol + url.host' to
'url.origin', which does essentially the same but is simpler.
Signed-off-by: Edgar Silva <edgar.silva@cross-join.com>
Updated integration module to allow for the use of a custom port, which
is often the case in self hosted gitlab instances
Removed host.includes(':') check in config.ts to allow for users to
include the port in the host
Changed url.hostname to url.host in core.ts to include the port in the
api call (otherwise it'll result in an error when trying to import a new
component)
Signed-off-by: Edgar Silva <edgar.silva@cross-join.com>
While this is less obvious to the user this facilitates anonymous access
to (public) files where the app is installed but the owner is not in the
allowed list.
Signed-off-by: Iain Billett <iain@roadie.io>
There is now two credentials providers:
- SingleInstanceGithubCredentialsProvider can be created with a single
GitHubIntegrationConfig.
- DefaultGithubCredentialsProvider is created from the full integrations
config.
Signed-off-by: Brian Fletcher <brian@roadie.io>
This change required the SingleInstanceGithubCredentialsProvider to be
changed to allow it to look up the credentials from the whole list of
integrations.
As such all places where it was used I have updated.
Signed-off-by: Brian Fletcher <brian@roadie.io>
We plan to build on this later to allow the credentials provider to
be passed into the scaffolder tasks, the processors, and the url
readers.
Signed-off-by: Brian Fletcher <brian@roadie.io>