← Back to issue list

Charmcraft 3 should still accept image digests for `upload-resource`

View original Github issue

Metadata

Project
charmcraft
Number
#1953
Type
issue
State
open
Author
lengau
Labels
Created
2024-10-10 16:30:24+00:00
Updated
2025-08-15 15:18:07+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description Charmcraft 3 doesn't accept digests, just image IDs, when uploading a resource. Solution: Reimplement [this method](https://github.com/canonical/charmcraft/blob/c13f20ae65b6a4d3657dcdd30b2f606ccae86163/charmcraft/commands/store/registry.py#L314-L342) on the ImageService. It can use Docker's [images.list()](https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.list) method and find the digest under `image.attrs["RepoDigests"]`. Note that these digests are in `<name>@<hash-algo>:<hash>` form, so you'll need to check if it matches a regex something like `".+@([a-z0-9]+:)?{digest}"` (so it works with just the hash or algo:hash). ### To Reproduce See: https://discourse.charmhub.io/t/publish-your-charm-on-charmhub/12281/6?u=lengau ### Environment n/a ### charmcraft.yaml ```yaml n/a ``` ### Relevant log output ```shell $ charmcraft upload-resource loki-worker-k8s loki-image --image=sha256:583ddc10f52bb4fe4806baa05ecbaa2a3246238f1423bd2a6c35b02fd87b446c Unknown OCI image reference. Recommended resolution: Pass a valid container transport string. Full execution log: '/home/jose/.local/state/charmcraft/log/charmcraft-20240801-171905.784405.log' ```

Evaluation history

No evaluation history available.