lirantal / dockly

Immersive terminal interface for managing docker containers and services
https://lirantal.github.io/dockly/
MIT License
3.79k stars 151 forks source link

[Bug]: Docker image without a digest or tag crashes the imageList.widget #246

Closed saemik94 closed 1 year ago

saemik94 commented 1 year ago

What went wrong?

Hi there Great job you did here, I really like your tool and I already recommended dockly to serveral friends :)

I stumbled over an issue after creating some local docker images. The local built images don't have a digest or tag and this leads to a bug in the imageList.widget and then the application crashes: local-images Empty digest: error1

It's on immageList.widget line 52, at this point image.RepoDigests is of type object and it's value is an empty array. So the if statement evaluates to true and the split on image.RepoDigests[0] fails and leads to the crash.

Empty tag: error2

It's on immageList.widget line 48, at this point the if statement, to check the tag value evaluates to true. Therefore the split leads then to the crash.

Proposed solution: immageList.widget line 52 image.RepoDigests?.length ? image.RepoDigests[0].split('@')[0] : getTag(image[2], 0),

immageList.widget line 48 const getTag = (tag, part) => tag?.length ? tag[0].split(':')[part] : 'none'

With those two changes dockly runs as smooth as always, when I build it locally. If you would like, I can also create a pull request. Either way I hope I could help a little.

Your environment setup

lirantal commented 1 year ago

@saemik94 thank you for the kind words ❤️ would indeed be great if you wanted to send over a pull request and we'll happily merge and publish a new release.

saemik94 commented 1 year ago

The fix was successfully tested in version 3.23.1, the issue is closed.