Skip to content

Commit

Permalink
fix: can't inspect ubuntu:24.04 with Podman (wagoodman#476)
Browse files Browse the repository at this point in the history
The problem was caused by `net/url.Parse()`:
```
panic: parse "podman://ubuntu:24.04": invalid port ":24.04" after host
```

Failure:
```
$ ./dive podman://ubuntu:24.04
Image Source: docker://podman://ubuntu:24.04
Fetching image... (this can take a while for large images)
Handler not available locally. Trying to pull 'podman://ubuntu:24.04'...
cannot fetch image
cannot find docker client executable
```

Success:
```
$ ./dive podman://ubuntu:24.04
Image Source: podman://ubuntu:24.04
...

$ ./dive ubuntu:24.04 --source podman
Image Source: podman://ubuntu:24.04
...

$ ./dive podman://ubuntu:24.04 --source docker
Image Source: podman://ubuntu:24.04
...
```

Fixes wagoodman#475

Co-authored-by: Anatoli Babenia <[email protected]>
  • Loading branch information
joschi and abitrolly committed Nov 7, 2024
1 parent 77d530d commit ad250f0
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 ad250f0

Please sign in to comment.