summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2019-06-28 10:55:10 +0000
committerBob Van Landuyt <bob@gitlab.com>2019-06-28 10:55:10 +0000
commite17edd37ab3a33d874d6ad7af92f0f5045d970c7 (patch)
tree3665d4846b9aa27bc12e22f9c50db72845187554
parent5ee5b280b05f63768f359d0b82d5edd490c0e7cd (diff)
parent2b4d755df14871a3b77bbfc219d6dd350dbc7667 (diff)
downloadgitlab-ce-e17edd37ab3a33d874d6ad7af92f0f5045d970c7.tar.gz
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
-rw-r--r--.gitlab/CODEOWNERS2
-rw-r--r--db/migrate/20190613073003_create_project_aliases.rb16
-rw-r--r--db/schema.rb10
-rw-r--r--doc/api/project_aliases.md105
-rw-r--r--doc/user/permissions.md5
-rw-r--r--doc/user/project/index.md23
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
7 files changed, 162 insertions, 0 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS
index 0ca6d7a350a..f65e62068d6 100644
--- a/.gitlab/CODEOWNERS
+++ b/.gitlab/CODEOWNERS
@@ -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
diff --git a/db/migrate/20190613073003_create_project_aliases.rb b/db/migrate/20190613073003_create_project_aliases.rb
new file mode 100644
index 00000000000..5a2c2ba0cf2
--- /dev/null
+++ b/db/migrate/20190613073003_create_project_aliases.rb
@@ -0,0 +1,16 @@
+# 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
diff --git a/db/schema.rb b/db/schema.rb
index 054dbc7201f..87a935ee08e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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
diff --git a/doc/api/project_aliases.md b/doc/api/project_aliases.md
new file mode 100644
index 00000000000..65845579409
--- /dev/null
+++ b/doc/api/project_aliases.md
@@ -0,0 +1,105 @@
+# 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"
+```
diff --git a/doc/user/permissions.md b/doc/user/permissions.md
index 7af3d4a0ac3..03abef9fc62 100644
--- a/doc/user/permissions.md
+++ b/doc/user/permissions.md
@@ -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.
diff --git a/doc/user/project/index.md b/doc/user/project/index.md
index 587b4121e4e..06286951e20 100644
--- a/doc/user/project/index.md
+++ b/doc/user/project/index.md
@@ -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)
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 7a250603b6b..7baa52ffb4f 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -397,6 +397,7 @@ project:
- incident_management_setting
- merge_trains
- designs
+- project_aliases
award_emoji:
- awardable
- user