@@ -30,7 +30,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
3030 Short : "Remove build cache" ,
3131 Args : cli .NoArgs ,
3232 RunE : func (cmd * cobra.Command , args []string ) error {
33- spaceReclaimed , output , err := runPrune (dockerCli , options )
33+ spaceReclaimed , output , err := runPrune (cmd . Context (), dockerCli , options )
3434 if err != nil {
3535 return err
3636 }
@@ -58,7 +58,7 @@ const (
5858 allCacheWarning = `WARNING! This will remove all build cache. Are you sure you want to continue?`
5959)
6060
61- func runPrune (dockerCli command.Cli , options pruneOptions ) (spaceReclaimed uint64 , output string , err error ) {
61+ func runPrune (ctx context. Context , dockerCli command.Cli , options pruneOptions ) (spaceReclaimed uint64 , output string , err error ) {
6262 pruneFilters := options .filter .Value ()
6363 pruneFilters = command .PruneFilters (dockerCli , pruneFilters )
6464
@@ -70,7 +70,7 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6
7070 return 0 , "" , nil
7171 }
7272
73- report , err := dockerCli .Client ().BuildCachePrune (context . Background () , types.BuildCachePruneOptions {
73+ report , err := dockerCli .Client ().BuildCachePrune (ctx , types.BuildCachePruneOptions {
7474 All : options .all ,
7575 KeepStorage : options .keepStorage .Value (),
7676 Filters : pruneFilters ,
@@ -93,6 +93,6 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6
9393}
9494
9595// CachePrune executes a prune command for build cache
96- func CachePrune (dockerCli command.Cli , all bool , filter opts.FilterOpt ) (uint64 , string , error ) {
97- return runPrune (dockerCli , pruneOptions {force : true , all : all , filter : filter })
96+ func CachePrune (ctx context. Context , dockerCli command.Cli , all bool , filter opts.FilterOpt ) (uint64 , string , error ) {
97+ return runPrune (ctx , dockerCli , pruneOptions {force : true , all : all , filter : filter })
9898}
0 commit comments