func (e *DockerEngine) ImageDigest(image string) string {
cmd := buildCmd("docker", "inspect", "--format", "{{index .RepoDigests 0}}", image)
out, err := cmd.Output()
if err != nil {
return ""
}
return strings.TrimSpace(string(out))
}
RepoDigests is populated by pulling from a registry. An image built locally, loaded from an archive, or tagged from another local image has none, so the index fails and this returns "" — the same answer it gives for an image that is not on the machine at all.
Observed as Doctor reporting Omnideck download: warn — Could not confirm the downloaded app image, which reads like a problem with the download rather than "this image did not come from a registry".
Suggestion
Now that ImageExists is on the engine interface, callers that want presence should ask that, and ImageDigest should be understood as "the registry digest, if it has one". Worth auditing the callers and, where the distinction matters, reporting unknown rather than missing.
RepoDigestsis populated by pulling from a registry. An image built locally, loaded from an archive, or tagged from another local image has none, so the index fails and this returns""— the same answer it gives for an image that is not on the machine at all.Observed as Doctor reporting
Omnideck download: warn — Could not confirm the downloaded app image, which reads like a problem with the download rather than "this image did not come from a registry".Suggestion
Now that
ImageExistsis on the engine interface, callers that want presence should ask that, andImageDigestshould be understood as "the registry digest, if it has one". Worth auditing the callers and, where the distinction matters, reporting unknown rather than missing.