Closed jasonbrancazio closed 1 year ago
Update: I noticed that the Artifact Registry REST API does not have a delete method for dockerImages either. If you inspect network traffic as you manually delete an image using the Artifact Registry cloud console, you'll see that instead of deleting an image by its tag, it actually deletes a version of a package.
Knowing this substitution logic, you can do the following, given a client
of type google.cloud.artifactregistry_v1.services.artifact_registry.client.ArtifactRegistryClient
and a variable my_image
of type google.cloud.artifactregistry_v1.types.artifact.DockerImage
:
name = my_image.name.replace("dockerImages","packages").replace("@","/versions/")
request = DeleteVersionRequest({"name":name,"force":True}) # force True to delete images with tags
client.delete_version(request=request)
The proposed delete_docker_image
method would accept a name formatted the way a DockerImage
returned by a client.list_images
response is: projects/PROJECT/locations/LOCATION/repositories/REPOSITORY/dockerImages/IMAGE@sha256:HASH
and use code similar to that provided above to do the conversion behind the scenes and submit a DeleteVersionRequest
.
Thanks @jasonbrancazio for providing the workaround! I too would be interested in this addition!
Thanks for reporting this feature request. I've filed https://issuetracker.google.com/issues/278218138 for the API team to take a look. I'm going to close this issue as a duplicate of https://issuetracker.google.com/issues/278218138.
The ArtifactRegistryClient has
get_docker_image
andlist_docker_images
methods, but nodelete_docker_image
method. This is inconsistent with the methods exposed for packages, repositories, tags, and versions, all of which have a delete method.My use case: I have many untagged Docker images in a Registry. I want to loop over all of them with the list_docker_images method, find the ones that have no tags, and delete them.