cli/command/image: remove errdefs uses

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-05-16 20:11:32 +02:00
parent c4009463a7
commit 214d2bfb6b
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -11,8 +11,7 @@ import (
"github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/internal/prompt" "github.com/docker/cli/internal/prompt"
"github.com/docker/cli/opts" "github.com/docker/cli/opts"
"github.com/docker/docker/errdefs" "github.com/docker/go-units"
units "github.com/docker/go-units"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -76,7 +75,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return 0, "", err return 0, "", err
} }
if !r { if !r {
return 0, "", errdefs.Cancelled(errors.New("image prune has been cancelled")) return 0, "", cancelledErr{errors.New("image prune has been cancelled")}
} }
} }
@ -106,6 +105,10 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return spaceReclaimed, output, nil return spaceReclaimed, output, nil
} }
type cancelledErr struct{ error }
func (cancelledErr) Cancelled() {}
// RunPrune calls the Image Prune API // RunPrune calls the Image Prune API
// This returns the amount of space reclaimed and a detailed output string // This returns the amount of space reclaimed and a detailed output string
func RunPrune(ctx context.Context, dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { func RunPrune(ctx context.Context, dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) {