-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathrm.go
More file actions
49 lines (44 loc) · 1.11 KB
/
rm.go
File metadata and controls
49 lines (44 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package manifest
import (
"context"
"errors"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
manifeststore "github.com/docker/cli/cli/manifest/store"
"github.com/spf13/cobra"
)
func newRmManifestListCommand(dockerCLI command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "rm MANIFEST_LIST [MANIFEST_LIST...]",
Short: "Delete one or more manifest lists from local storage",
Args: cli.RequiresMinArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runRemove(cmd.Context(), newManifestStore(dockerCLI), args)
},
DisableFlagsInUseLine: true,
}
return cmd
}
func runRemove(ctx context.Context, store manifeststore.Store, targets []string) error {
var errs []error
for _, target := range targets {
if ctx.Err() != nil {
return ctx.Err()
}
targetRef, err := normalizeReference(target)
if err != nil {
errs = append(errs, err)
continue
}
_, err = store.GetList(targetRef)
if err != nil {
errs = append(errs, err)
continue
}
err = store.Remove(targetRef)
if err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}