Skip to content

feat: Allow deleting images with imgspec#154

Open
jedevc wants to merge 1 commit intoprod-stagingfrom
jedevc/imgspec-delete
Open

feat: Allow deleting images with imgspec#154
jedevc wants to merge 1 commit intoprod-stagingfrom
jedevc/imgspec-delete

Conversation

@jedevc
Copy link
Collaborator

@jedevc jedevc commented Mar 4, 2026

We use the OCI image distribution protocol to allow deleting images, so as to free up a user's quota.

Fixes https://linear.app/unikraft/issue/TOOL-599/implement-unikraft-image-remove.

This comment was marked as resolved.


// DeleteDockerImage deletes a Docker image from a remote registry.
// XXX: can we simplify this method signature?
func DeleteDockerImage(ctx context.Context, named reference.Named, remote remotes.Resolver, hosts docker.RegistryHosts, headers http.Header) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're re-parsing the ref twice in this file, once to get the ctrd type and once to get a dist type, both times you are handling errors... the starting point is the output of remote.Resolve, which is guaranteed to be a valid ref?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. But I think it's returning the error in both cases right?

The alternatives are to panic (bad, why should the caller crash because of an internal error like this), or to ignore it and potentially produce a malformed destructive request.


func deleteDockerManifest(ctx context.Context, host docker.RegistryHost, headers http.Header, refHost string, repository string, dgst digest.Digest) error {
requestHeaders := http.Header{}
if headers != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you going to use the additional headers for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See tools/imgtool/resolver.go, I'm using it to set the User-Agent. We can't get it out of the resolver, since it's stored privately and not exposed.

@jedevc jedevc force-pushed the jedevc/imgspec-delete branch 2 times, most recently from 3dadf9c to 27d5539 Compare March 17, 2026 10:33
@jedevc jedevc requested a review from robertgzr March 17, 2026 10:33
Signed-off-by: Justin Chadwell <justin@unikraft.com>
@jedevc jedevc force-pushed the jedevc/imgspec-delete branch from 27d5539 to 0cf6590 Compare March 18, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants