feat(create): implement --compatibility to fetch supported image list#2111
Merged
Conversation
dottorblaster
requested changes
May 27, 2026
dottorblaster
left a comment
Collaborator
There was a problem hiding this comment.
Just one thing but then we can merge 👍
Comment on lines
+282
to
+313
| // first line that starts with "| Alma" and the next line that starts with | ||
| // "| Void". Returned slice is sorted and deduplicated, mirroring the | ||
| // `sort -u` behaviour of the original bash implementation. | ||
| func parseCompatibilityImages(markdown string) []string { | ||
| seen := make(map[string]struct{}) | ||
|
|
||
| inTable := false | ||
| for _, line := range strings.Split(markdown, "\n") { | ||
| if !inTable { | ||
| if strings.HasPrefix(line, compatibilityTableStartMarker) { | ||
| inTable = true | ||
| } else { | ||
| continue | ||
| } | ||
| } | ||
|
|
||
| for _, image := range extractImagesFromRow(line) { | ||
| seen[image] = struct{}{} | ||
| } | ||
|
|
||
| if strings.HasPrefix(line, compatibilityTableEndMarker) { | ||
| break | ||
| } | ||
| } | ||
|
|
||
| images := make([]string, 0, len(seen)) | ||
| for image := range seen { | ||
| images = append(images, image) | ||
| } | ||
| sort.Strings(images) | ||
| return images | ||
| } |
Collaborator
There was a problem hiding this comment.
The table boundaries "| Alma" and "| Void" are extremely fragile structural markers.
Any of the following silently breaks with an error about parsing compatibility list:
- AlmaLinux renamed/removed
- a new distro added alphabetically before "Alma"
- Void renamed
- a new distro added alphabetically after "Void"
Two suggestions:
- Anchor on the
## Containers Distrosheading and the next## headinginstead of arbitrary cell content - When the markers can't be found, return an explicit error like compatibility table layout changed in upstream
docs/compatibility.md.
I would especially pick the first one 😬
Collaborator
Author
There was a problem hiding this comment.
Done it. The previous implementation was mirroring what is done on main, but this is an improvement indeed
8e27494 to
e0b11fa
Compare
Ports show_compatibility from bash distrobox-create. Downloads docs/compatibility.md from upstream and caches the parsed list in the user cache dir. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4b28132 to
eb597d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
distrobox create --compatibilityflag in Go (resolves theTODOatinternal/cli/create.go:240), porting the bashshow_compatibilityhelper from the legacydistrobox-createscript.docs/compatibility.mdfrom upstream for the current build version (falling back tomainfordevbuilds, or to the nearest tag whengit describe --tagsproduces a<tag>-N-g<sha>[-dirty]suffix), parses the "Containers Distros" table, and caches the deduplicated/sorted image list under$XDG_CACHE_HOME/distrobox/distrobox-compatibility-<ref>so subsequent invocations are offline-friendly./,.., or unusual characters from creating nested paths or escaping the cache directory.context.Contextinto the HTTP fetch so Ctrl+C / parent cancellation aborts the request.Implementation notes
internal/cli/compatibility.gohouses the fetch / parse / cache logic.sed -n '/| Alma/,/| Void/ p' | cut -f4 | sed s/<br>/\n/ | tr -d ' ' | sort -u) line-by-line in Go.git describeshapes and bare hashes), ref sanitization for filename safety, the HTTP fetch helpers, and theXDG_CACHE_HOME/HOMEfallback chain.Test plan
make buildsucceedsmake testpasses (33 new tests ininternal/cli, full suite green)make lintpasses with zero issuesdistrobox create --compatibilityreturns 122 image entries on first invocation and serves from cache on the secondVERSION=dev: falls back tomainref and writesdistrobox-compatibility-main