Skip to content

Commit

Permalink
fix: Invert the API version error check (#78)
Browse files Browse the repository at this point in the history
* fix: Negate API version err check

* chore: Log all filters
  • Loading branch information
HofmeisterAn authored May 17, 2023
1 parent bfea399 commit 7710e89
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ func prune(cli *client.Client, deathNote *sync.Map) (deletedContainers int, dele
_ = try.Do(func(attempt int) (bool, error) {
argsClone := args.Clone()

if verbose {
log.Printf("Deleting volumes with filter: %#v. (Attempt %d/%d)\n", argsClone, attempt, 10)
// The API version >= v1.42 prunes only anonymous volumes: https://github.com/moby/moby/releases/tag/v23.0.0.
if serverVersion, err := cli.ServerVersion(context.Background()); err == nil && serverVersion.APIVersion >= "1.42" {
argsClone.Add("all", "true")
}

// API version >= v1.42 prunes only anonymous volumes: https://github.com/moby/moby/releases/tag/v23.0.0.
if serverVersion, err := cli.ServerVersion(context.Background()); err != nil && serverVersion.APIVersion >= "1.42" {
argsClone.Add("all", "true")
if verbose {
log.Printf("Deleting volumes with filter: %#v. (Attempt %d/%d)\n", argsClone, attempt, 10)
}

volumesPruneReport, err := cli.VolumesPrune(context.Background(), argsClone)
Expand Down

0 comments on commit 7710e89

Please sign in to comment.