Fix ImageExists to use skopeo instead of podman manifest inspect
podman manifest inspect only works for multi-arch manifest lists, returning exit code 125 for regular single-arch images. Switch to skopeo inspect which works for both. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -199,15 +199,16 @@ func (p *Podman) Push(ctx context.Context, image string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImageExists checks whether an image tag exists in a remote registry.
|
// ImageExists checks whether an image tag exists in a remote registry.
|
||||||
|
// Uses skopeo inspect which works for both regular images and multi-arch
|
||||||
|
// manifests, unlike podman manifest inspect which only handles manifests.
|
||||||
func (p *Podman) ImageExists(ctx context.Context, image string) (bool, error) {
|
func (p *Podman) ImageExists(ctx context.Context, image string) (bool, error) {
|
||||||
cmd := exec.CommandContext(ctx, p.command(), "manifest", "inspect", "docker://"+image) //nolint:gosec // args built programmatically
|
cmd := exec.CommandContext(ctx, "skopeo", "inspect", "--tls-verify=false", "docker://"+image) //nolint:gosec // args built programmatically
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
// Exit code 1 means the manifest was not found.
|
|
||||||
var exitErr *exec.ExitError
|
var exitErr *exec.ExitError
|
||||||
if ok := errors.As(err, &exitErr); ok && exitErr.ExitCode() == 1 {
|
if ok := errors.As(err, &exitErr); ok && exitErr.ExitCode() != 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, fmt.Errorf("podman manifest inspect %q: %w", image, err)
|
return false, fmt.Errorf("skopeo inspect %q: %w", image, err)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user