Skip to content

Conversation

@tonyo
Copy link
Collaborator

@tonyo tonyo commented Oct 27, 2025

@psviderski thoughts on this? Lmk if there was no intention to do any "smarter" kind of matching on this API level.

This would slightly simplify it for #139 (since people will only have access to the short ID and that's what they'll be pasting to exec --container, but no big deal to write a small wrapper there.

Alternatively: I can add another function like InspectContainerFuzzy or similar.

Copy link
Owner

@psviderski psviderski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it, I like it! 👍

if c.Container.ID == containerNameOrID || c.Container.Name == containerNameOrID {
if c.Container.ID == containerNameOrID ||
c.Container.Name == containerNameOrID ||
stringid.TruncateID(c.Container.ID) == containerNameOrID {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but we can go even further and support any ID prefix as docker does. Something like

strings.HasPrefix(c.Container.ID, containerNameOrID)

But in this case we shouldn't return right after the first match but instead compare the prefix against all containers. And return only if the prefix matches only one unique container.

Then a user will be able to type just a few first chars of the container id uc exec app --container ea0
It's up to you if you want to implement this right away. Otherwise supporting only 12-chars short IDs is fine as well.

Copy link
Collaborator Author

@tonyo tonyo Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added a TODO for that. Will need to think a bit more about edge cases, like a container's name being a prefix for some container id, or similar.

@tonyo tonyo merged commit 6af7a98 into main Oct 28, 2025
4 checks passed
@tonyo tonyo deleted the tonyo/inspect-container-short-1 branch October 28, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants