MCPcopy Create free account
hub / github.com/docker/cli / runPrune

Function runPrune

cli/command/network/prune.go:62–91  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, options pruneOptions)

Source from the content-addressed store, hash-verified

60Are you sure you want to continue?`
61
62func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, _ error) {
63 pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
64
65 if !options.force {
66 r, err := prompt.Confirm(ctx, dockerCli.In(), dockerCli.Out(), warning)
67 if err != nil {
68 return "", err
69 }
70 if !r {
71 return "", cancelledErr{errors.New("network prune has been cancelled")}
72 }
73 }
74
75 res, err := dockerCli.Client().NetworkPrune(ctx, client.NetworkPruneOptions{
76 Filters: pruneFilters,
77 })
78 if err != nil {
79 return "", err
80 }
81
82 var out strings.Builder
83 if len(res.Report.NetworksDeleted) > 0 {
84 out.WriteString("Deleted Networks:\n")
85 for _, id := range res.Report.NetworksDeleted {
86 out.WriteString(id + "\n")
87 }
88 }
89
90 return out.String(), nil
91}
92
93type cancelledErr struct{ error }
94

Callers 2

newPruneCommandFunction · 0.70
pruneFnFunction · 0.70

Calls 5

ValueMethod · 0.65
InMethod · 0.65
OutMethod · 0.65
ClientMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…