fix: prune volumes without all flag for pre-Docker v1.42 #2781
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.
What kind of change does this PR introduce?
Bug fix for
supabase stop --no-backup
for users on old versions of Docker or on Podman.What is the current behavior?
Before Docker API version 1.42, the
all
flag inDocker.VolumePrune
is not required.Podman prints an error like the following when the
all
flag is passed (Podman's only compatible with Docker API v1.41), e.g. when runningsupabase stop --no-backup
:See: #2348 (comment), who had this same issue.
See: #1989 (which added the
all
flag)What is the new behavior?
I've added an
if versions.GreaterThanOrEqualTo(Docker.ClientVersion(), "1.42")
check before adding theall
flag.A similar check is done by the official Docker CLI: https://github.com/docker/cli/blob/062eecf14af34d7295da16c23c2578fcf4aa0196/cli/command/volume/prune.go#L67-L78
This works on Podman. I suspect it would work on older versions of Docker too, but I don't have one of those environments to test with!
Additional context
I'm a complete beginner in golang (this is only my second time writing a golang PR), so please review my code carefully. It's very likely I made a dumb mistake since I didn't know any better.