From 14122af881711a5cd99b21c802a4da7ada0b3941 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 14 Sep 2023 21:29:03 +0300 Subject: [PATCH] Fix #475 - can't inspect docker:23.0.1 with podman MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem was caused by net/url.Parse() panic: parse "podman://docker:23.0.1": invalid port ":23.0.1" after host Testing the fix ✗ ./dive podman://docker:23.0.1 Image Source: podman://docker:23.0.1 ✗ ./dive podman://docker:23.0.1 --source docker Image Source: podman://docker:23.0.1 ✗ ./dive docker:23.0.1 --source podman Image Source: podman://docker:23.0.1 --- dive/get_image_resolver.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dive/get_image_resolver.go b/dive/get_image_resolver.go index 05d95ab0..4d53ed91 100644 --- a/dive/get_image_resolver.go +++ b/dive/get_image_resolver.go @@ -2,7 +2,6 @@ package dive import ( "fmt" - "net/url" "strings" "github.com/wagoodman/dive/dive/image" @@ -41,14 +40,13 @@ func ParseImageSource(r string) ImageSource { } func DeriveImageSource(image string) (ImageSource, string) { - u, err := url.Parse(image) - if err != nil { + s := strings.SplitN(image, "://", 2) + if len(s) < 2 { return SourceUnknown, "" } + scheme, imageSource := s[0], s[1] - imageSource := strings.TrimPrefix(image, u.Scheme+"://") - - switch u.Scheme { + switch scheme { case SourceDockerEngine.String(): return SourceDockerEngine, imageSource case SourcePodmanEngine.String():