With [a fix][1] in [podman v3.4.3][2], these commands now work as
expected in macOS. Potentially, it might make sense to version check
podman to ensure that the minimum version is met, but I'm not sure
that's needed because it's unlikely that people have an older version
installed _and_ wish to use this tool.
I'm unsure whether the commands work on Windows so I left the
unsupported version there compiling with the negation of the supported
flags.
[1]: https://github.com/containers/podman/issues/12402
[2]: 4ba71f955a/RELEASE_NOTES.md (bugfixes-2)
49 lines
976 B
Go
49 lines
976 B
Go
// +build linux darwin
|
|
|
|
package podman
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/wagoodman/dive/dive/image"
|
|
"github.com/wagoodman/dive/dive/image/docker"
|
|
"io/ioutil"
|
|
)
|
|
|
|
type resolver struct{}
|
|
|
|
func NewResolverFromEngine() *resolver {
|
|
return &resolver{}
|
|
}
|
|
|
|
func (r *resolver) Build(args []string) (*image.Image, error) {
|
|
id, err := buildImageFromCli(args)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return r.Fetch(id)
|
|
}
|
|
|
|
func (r *resolver) Fetch(id string) (*image.Image, error) {
|
|
// todo: add podman fetch attempt via varlink first...
|
|
|
|
img, err := r.resolveFromDockerArchive(id)
|
|
if err == nil {
|
|
return img, err
|
|
}
|
|
|
|
return nil, fmt.Errorf("unable to resolve image '%s': %+v", id, err)
|
|
}
|
|
|
|
func (r *resolver) resolveFromDockerArchive(id string) (*image.Image, error) {
|
|
err, reader := streamPodmanCmd("image", "save", id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
img, err := docker.NewImageArchive(ioutil.NopCloser(reader))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return img.ToImage()
|
|
}
|