Commit e17edd37 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '3264-project-aliases-ce' into 'master'

CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14108

See merge request gitlab-org/gitlab-ce!29604
parents 5ee5b280 2b4d755d
......@@ -19,3 +19,5 @@ db/ @abrandl @NikolayS
/lib/gitlab/ci/templates/ @nolith @zj
/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @DylanGriffith @mayra-cabrera @tkuah
/lib/gitlab/ci/templates/Security/ @plafoucriere @gonzoyumo @twoodham
/ee/app/models/project_alias.rb @patrickbajao
/ee/lib/api/project_aliases.rb @patrickbajao
# frozen_string_literal: true
class CreateProjectAliases < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :project_aliases do |t|
t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer
t.string :name, null: false, index: { unique: true }
t.timestamps_with_timezone null: false
end
end
end
......@@ -2412,6 +2412,15 @@ ActiveRecord::Schema.define(version: 20190625184066) do
t.string "encrypted_token_iv", null: false
end
create_table "project_aliases", force: :cascade do |t|
t.integer "project_id", null: false
t.string "name", null: false
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.index ["name"], name: "index_project_aliases_on_name", unique: true, using: :btree
t.index ["project_id"], name: "index_project_aliases_on_project_id", using: :btree
end
create_table "project_authorizations", id: false, force: :cascade do |t|
t.integer "user_id", null: false
t.integer "project_id", null: false
......@@ -3793,6 +3802,7 @@ ActiveRecord::Schema.define(version: 20190625184066) do
add_foreign_key "pool_repositories", "projects", column: "source_project_id", on_delete: :nullify
add_foreign_key "pool_repositories", "shards", on_delete: :restrict
add_foreign_key "project_alerting_settings", "projects", on_delete: :cascade
add_foreign_key "project_aliases", "projects", on_delete: :cascade
add_foreign_key "project_authorizations", "projects", on_delete: :cascade
add_foreign_key "project_authorizations", "users", on_delete: :cascade
add_foreign_key "project_auto_devops", "projects", on_delete: :cascade
......
# Project Aliases API **[PREMIUM ONLY]**
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/3264) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.1.
All methods require administrator authorization.
## List all project aliases
Get a list of all project aliases:
```
GET /project_aliases
```
```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases"
```
Example response:
```json
[
{
"id": 1,
"project_id": 1,
"name": "gitlab-ce"
},
{
"id": 2,
"project_id": 2,
"name": "gitlab-ee"
}
]
```
## Get project alias' details
Get details of a project alias:
```
GET /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab-ee"
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab-ee"
}
```
## Create a project alias
Add a new alias for a project. Responds with a 201 when successful,
400 when there are validation errors (e.g. alias already exists):
```
POST /project_aliases
```
| Attribute | Type | Required | Description |
|--------------|--------|----------|-----------------------------------------------|
| `project_id` | string | yes | The ID or URL-encoded path of the project. |
| `name` | string | yes | The name of the alias. Must be unique. |
```
curl --request POST "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=gitlab-org%2Fgitlab-ee" --form "name=gitlab-ee"
```
Example response:
```json
{
"id": 1,
"project_id": 1,
"name": "gitlab-ee"
}
```
## Delete a project alias
Removes a project aliases. Responds with a 204 when project alias
exists, 404 when it doesn't:
```
DELETE /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab-ee"
```
......@@ -365,3 +365,8 @@ for details about the pipelines security model.
Since GitLab 8.15, LDAP user permissions can now be manually overridden by an admin user.
Read through the documentation on [LDAP users permissions](../administration/auth/how_to_configure_ldap_gitlab_ee/index.html) to learn more.
## Project aliases
Project aliases can only be read, created and deleted by a GitLab administrator.
Read through the documentation on [Project aliases](../user/project/index.md#project-aliases-premium-only) to learn more.
......@@ -193,6 +193,28 @@ password <personal_access_token>
To quickly access a project from the GitLab UI using the project ID,
visit the `/projects/:id` URL in your browser or other tool accessing the project.
## Project aliases **[PREMIUM ONLY]**
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/3264) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.1.
When migrating repositories to GitLab and they are being accessed by other systems,
it's very useful to be able to access them using the same name especially when
they are a lot. It reduces the risk of changing significant number of Git URLs in
a large number of systems.
GitLab provides a functionality to help with this. In GitLab, repositories are
usually accessed with a namespace and project name. It is also possible to access
them via a project alias. This feature is only available on Git over SSH.
A project alias can be only created via API and only by GitLab administrators.
Follow the [Project Aliases API documentation](../../api/project_aliases.md) for
more details.
Once an alias has been created for a project (e.g., an alias `gitlab-ce` for the
project `https://gitlab.com/gitlab-org/gitlab-ce`), the repository can be cloned
using the alias (e.g `git clone git@gitlab.com:gitlab-ce.git` instead of
`git clone git@gitlab.com:gitlab-org/gitlab-ce.git`).
## Project APIs
There are numerous [APIs](../../api/README.md) to use with your projects:
......@@ -212,3 +234,4 @@ There are numerous [APIs](../../api/README.md) to use with your projects:
- [Templates](../../api/project_templates.md)
- [Traffic](../../api/project_statistics.md)
- [Variables](../../api/project_level_variables.md)
- [Aliases](../../api/project_aliases.md)
......@@ -397,6 +397,7 @@ project:
- incident_management_setting
- merge_trains
- designs
- project_aliases
award_emoji:
- awardable
- user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment