Skip to content

Commit

Permalink
Fix #475 - can't inspect docker:23.0.1 with podman
Browse files Browse the repository at this point in the history
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
  • Loading branch information
abitrolly committed Sep 14, 2024
1 parent 4957b74 commit 14122af
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dive/get_image_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dive

import (
"fmt"
"net/url"
"strings"

"github.com/wagoodman/dive/dive/image"
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 14122af

Please sign in to comment.