diff options
author | Luke Bennett <lbennett@gitlab.com> | 2019-01-12 05:55:24 +0000 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2019-02-18 19:46:05 +0000 |
commit | 641330ed69d6df4dde5637478348712d561a9317 (patch) | |
tree | 0d81c514ca9c5d54ffe08a80b0e41c8d2cf79e0a | |
parent | 85de6904e57a65def1e15e695c3b717a3601433f (diff) | |
download | gitlab-ce-fix-destroy-remote-mirror-pull.tar.gz |
Fix deleting pull mirror in project repo settingsfix-destroy-remote-mirror-pull
Pull mirrors were only being disabled when a user clicks the
project repo settings UI delete button.
This commit adds a pull mirror delete endpoint that correctly
destroys the database record.
It is important to correctly delete pull mirrors when the user
expects it as credentials are present in `import_data_attributes`.
-rw-r--r-- | app/assets/javascripts/api.js | 10 | ||||
-rw-r--r-- | app/assets/javascripts/mirrors/mirror_repos.js | 8 | ||||
-rw-r--r-- | changelogs/unreleased/11-7-fix-destroy-remote-mirror-pull-only.yml | 5 | ||||
-rw-r--r-- | doc/api/README.md | 83 | ||||
-rw-r--r-- | doc/api/project_mirror.md | 41 | ||||
-rw-r--r-- | doc/api/project_remote_mirrors.md | 6 | ||||
-rw-r--r-- | doc/api/projects.md | 4 |
7 files changed, 151 insertions, 6 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 093762e823e..900ec9f4a67 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -30,6 +30,7 @@ const Api = { commitPipelinesPath: '/:project_id/commit/:sha/pipelines', branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch', createBranchPath: '/api/:version/projects/:id/repository/branches', + projectPullMirrorPath: '/api/:version/projects/:project_id/mirror', releasesPath: '/api/:version/projects/:id/releases', projectRemoteMirrorPath: '/api/:version/projects/:project_id/remote_mirrors/:remote_mirror_id', @@ -322,6 +323,15 @@ const Api = { return axios.get(url); }, + deleteProjectPullMirror(projectId) { + const url = Api.buildUrl(this.projectPullMirrorPath).replace( + ':project_id', + encodeURIComponent(projectId), + ); + + return axios.delete(url); + }, + deleteProjectRemoteMirror(projectId, remoteMirrorId) { const url = Api.buildUrl(this.projectRemoteMirrorPath) .replace(':project_id', encodeURIComponent(projectId)) diff --git a/app/assets/javascripts/mirrors/mirror_repos.js b/app/assets/javascripts/mirrors/mirror_repos.js index ae19f182c58..ce6b73a0536 100644 --- a/app/assets/javascripts/mirrors/mirror_repos.js +++ b/app/assets/javascripts/mirrors/mirror_repos.js @@ -64,7 +64,9 @@ export default class MirrorRepos { this.debouncedUpdateUrl = _.debounce(() => this.updateUrl(), 200); this.$urlInput.on('input', () => this.debouncedUpdateUrl()); this.$protectedBranchesInput.on('change', () => this.updateProtectedBranches()); - this.$table.on('click', '.js-delete-mirror', event => this.deleteMirror(event)); + this.$table.on('click', '.js-delete-mirror', event => + this.deleteMirror($(event.currentTarget)), + ); } togglePassword() { @@ -77,9 +79,7 @@ export default class MirrorRepos { this.$passwordGroup.collapse(isPassword ? 'show' : 'hide'); } - deleteMirror(event) { - const $target = $(event.currentTarget); - + deleteMirror($target) { return Api.deleteProjectRemoteMirror(this.$form.data('projectId'), $target.data('mirrorId')) .then(() => this.removeRow($target)) .catch(({ response }) => { diff --git a/changelogs/unreleased/11-7-fix-destroy-remote-mirror-pull-only.yml b/changelogs/unreleased/11-7-fix-destroy-remote-mirror-pull-only.yml new file mode 100644 index 00000000000..78b18bf3cf8 --- /dev/null +++ b/changelogs/unreleased/11-7-fix-destroy-remote-mirror-pull-only.yml @@ -0,0 +1,5 @@ +--- +title: Fix deleting pull mirror in project repo settings +merge_request: 25225 +author: +type: security diff --git a/doc/api/README.md b/doc/api/README.md index f14b4a6e53e..8f413a124e5 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -52,6 +52,7 @@ The following API resources are available in the project context: | [Project-level variables](project_level_variables.md) | `/projects/:id/variables` | | [Project import/export](project_import_export.md) | `/projects/:id/export`, `/projects/import`, `/projects/:id/import` | | [Project milestones](milestones.md) | `/projects/:id/milestones` | +| [Project mirror](project_mirror.md) | `/projects/:id/mirror` | | [Project remote mirrors](project_remote_mirrors.md) | `/projects/:id/remote_mirrors` | | [Project snippets](project_snippets.md) | `/projects/:id/snippets` | | [Project templates](project_templates.md) | `/projects/:id/templates` | @@ -125,6 +126,88 @@ The following API resources are available outside of project and group contexts ### Templates API resources +## API Resources + +The following API resources are available: + +- [Applications](applications.md) +- [Avatar](avatar.md) +- [Award emoji](award_emoji.md) +- [Branches](branches.md) +- [Broadcast messages](broadcast_messages.md) +- [Code snippets](snippets.md) +- [Commits](commits.md) +- [Container Registry](container_registry.md) +- [Custom attributes](custom_attributes.md) +- [Deploy keys](deploy_keys.md), and [deploy keys for multiple projects](deploy_key_multiple_projects.md) +- [Deployments](deployments.md) +- [Discussions](discussions.md) (threaded comments) +- [Environments](environments.md) +- [Events](events.md) +- [Feature flags](features.md) +- Group-related resources, including: + - [Groups](groups.md) + - [Group access requests](access_requests.md) + - [Group badges](group_badges.md) + - [Group issue boards](group_boards.md) + - [Group labels](group_labels.md) + - [Group-level variables](group_level_variables.md) + - [Group members](members.md) + - [Group milestones](group_milestones.md) +- [Issues](issues.md) +- [Issue boards](boards.md) +- [Jobs](jobs.md) +- [Keys](keys.md) +- [Labels](labels.md) +- [Markdown](markdown.md) +- [Merge requests](merge_requests.md) +- [Namespaces](namespaces.md) +- [Notes](notes.md) (comments) +- [Notification settings](notification_settings.md) +- [Pages domains](pages_domains.md) +- [Pipelines](pipelines.md) +- [Pipeline schedules](pipeline_schedules.md) +- [Pipeline triggers](pipeline_triggers.md) and [triggering pipelines](../ci/triggers/README.md) +- Project-related resources, including: + - [Projects](projects.md) including setting Webhooks + - [Project access requests](access_requests.md) + - [Project badges](project_badges.md) + - [Project clusters](project_clusters.md) + - [Project-level variables](project_level_variables.md) + - [Project import/export](project_import_export.md) + - [Project import from GitHub](import.md) + - [Project remote mirrors](project_remote_mirrors.md) + - [Project mirror](project_mirror.md) + - [Project members](members.md) + - [Project milestones](milestones.md) + - [Project snippets](project_snippets.md) + - [Project templates](project_templates.md) (see also [Templates API Resources](#templates-api-resources)) +- [Protected branches](protected_branches.md) +- [Protected tags](protected_tags.md) +- [Repositories](repositories.md) +- [Repository files](repository_files.md) +- [Repository submodules](repository_submodules.md) +- [Resource label events](resource_label_events.md) +- [Runners](runners.md) +- [Search](search.md) +- [Services](services.md) +- [Settings](settings.md) +- [Sidekiq metrics](sidekiq_metrics.md) +- [System hooks](system_hooks.md) +- [Tags](tags.md) +- [Releases](releases/index.md) +- Release Assets + - [Links](releases/links.md) +- [Todos](todos.md) +- [Users](users.md) +- [Validate CI configuration](lint.md) (linting) +- [Version](version.md) +- [Wikis](wikis.md) + +See also [V3 to V4](v3_to_v4.md). + +### Templates API Resources + Endpoints are available for: - [Dockerfile templates](templates/dockerfiles.md). diff --git a/doc/api/project_mirror.md b/doc/api/project_mirror.md new file mode 100644 index 00000000000..116f168ff6e --- /dev/null +++ b/doc/api/project_mirror.md @@ -0,0 +1,41 @@ +# Project mirror API + +A project's mirror is its pull mirror. + +A project mirror is not the same as remote mirrors, which are push mirrors. +There is seperate documentation for the [remote mirrors API](project_remote_mirrors.md). + +There is +[an issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/51763) +to improve the naming of push and pull mirrors. + +## Start the pull mirroring process **[STARTER]** + +> Introduced in [GitLab Starter](https://about.gitlab.com/pricing) 10.3. + +``` +POST /projects/:id/mirror/pull +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) | + +```bash +curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/mirror/pull +``` + +## Delete a mirror + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/54574) in GitLab 11.8 + +Deletes the existing project mirror. + +``` +DELETE /projects/:id/mirror +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | + diff --git a/doc/api/project_remote_mirrors.md b/doc/api/project_remote_mirrors.md index bcf268bd421..cc361b7b5c3 100644 --- a/doc/api/project_remote_mirrors.md +++ b/doc/api/project_remote_mirrors.md @@ -2,7 +2,10 @@ > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/54574) in GitLab 11.8 -A project's remote mirrors are its push mirrors. Remote mirrors are not pull mirrors. +A project's remote mirrors are its push mirrors. + +Remote mirrors are not not the same as a project mirror, which is a pull mirror. +There is seperate documentation for the [project mirror API](project_mirror.md). There is [an issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/51763) @@ -21,4 +24,3 @@ DELETE /projects/:id/remote_mirrors/:remote_mirror_id | `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | | `remote_mirror_id` | integer | yes | The id of the project's remote mirror | - diff --git a/doc/api/projects.md b/doc/api/projects.md index 3c0c956ddc2..8d197d41434 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -1553,6 +1553,10 @@ Read more in the [Project import/export](project_import_export.md) documentation Read more in the [Project members](members.md) documentation. +## Project mirror + +Read more in the [Project mirror](project_mirror.md) documentation. + ## Project badges Read more in the [Project Badges](project_badges.md) documentation. |