cli/command/builder: remove errdefs uses

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

View File

@ -12,8 +12,7 @@ import (
"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/api/types/build" "github.com/docker/docker/api/types/build"
"github.com/docker/docker/errdefs" "github.com/docker/go-units"
units "github.com/docker/go-units"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -75,7 +74,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("builder prune has been cancelled")) return 0, "", cancelledErr{errors.New("builder prune has been cancelled")}
} }
} }
@ -101,6 +100,10 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
return report.SpaceReclaimed, output, nil return report.SpaceReclaimed, output, nil
} }
type cancelledErr struct{ error }
func (cancelledErr) Cancelled() {}
// CachePrune executes a prune command for build cache // CachePrune executes a prune command for build cache
func CachePrune(ctx context.Context, dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { func CachePrune(ctx context.Context, dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) {
return runPrune(ctx, dockerCli, pruneOptions{force: true, all: all, filter: filter}) return runPrune(ctx, dockerCli, pruneOptions{force: true, all: all, filter: filter})