This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for removing images/tags
Soft delete support has been supported in Docker Distribution since at least 2.1. This was not enough to implement the removal of images/tags in Portus because there was no support to GC these soft deleted blobs. Since 2.4, it's possible to not just delete the manifest, but also to GC blobs no longer referenced by any image manifest. This means that after being able to track digests, we can now safely provide image/tag removal support. For safety concerns, tags with an empty digest will not be allowed to be removed (this is more likely to be the case of Portus versions that have been running for some time). In previous PRs this has already been addressed, so admins can update their DB filling in the empty gaps (e.g. see PRs #825 or #830). The main downside of this change is that there is no way for a client to detect whether a remote registry supports GC. Because of this, a configuration option has been provided, which is disabled by default. The rationale is that administrators that are really sure about the availability of GC on their private registry will have to enable it explicitly. Fixes #197 Signed-off-by: Miquel Sabaté Solà <[email protected]>
- Loading branch information
Showing
31 changed files
with
663 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
.tags .label.label-success { | ||
margin: 0px 2px; | ||
} | ||
|
||
#remove-repo button { | ||
padding: 0px 10px 0px 0px; | ||
} | ||
|
||
.remove-repo:focus, .remove-repo:hover, .remove-tag:focus, .remove-tag:hover { | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# DeleteEnabeld redirects the user back if delete support is not enabled. A | ||
# `before_action` will be created for the :destroy method. | ||
module DeleteEnabled | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :delete_enabled?, only: [:destroy] | ||
end | ||
|
||
# Returns true if users can delete images/tags. | ||
def delete_enabled? | ||
redirect_to :back, status: :forbidden unless APP_CONFIG.enabled?("delete") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class TagsController < ApplicationController | ||
include DeleteEnabled | ||
|
||
# Removes all tags the match the digest of the tag with the given ID. | ||
# Moreover, it will also remove the image if it's left empty after removing | ||
# the tags. | ||
def destroy | ||
tag = Tag.find(params[:id]) | ||
|
||
# And now remove the tag by the digest. If the repository containing said | ||
# tags becomes empty after that, remove it too. | ||
repo = tag.repository | ||
if tag.delete_by_digest!(current_user) | ||
if repo.tags.empty? | ||
repo.delete_and_update!(current_user) | ||
redirect_to namespace_path(repo.namespace), notice: "Image removed with all its tags" | ||
else | ||
redirect_to repository_path(tag.repository), notice: "Tag removed successfully" | ||
end | ||
else | ||
redirect_to repository_path(tag.repository), alert: "Tag could not be removed" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.